Commit fa8351f8 by Jakub Jelinek Committed by Jakub Jelinek

re PR bootstrap/43699 ("variable set but not used" error during bootstrap)

	PR bootstrap/43699
	* c-typeck.c (c_process_expr_stmt): Call mark_exp_read even
	for exprs satisfying handled_component_p.

	* gcc.dg/Wunused-var-7.c: New test.

From-SVN: r158224
parent f101882a
2010-04-12 Jakub Jelinek <jakub@redhat.com>
PR bootstrap/43699
* c-typeck.c (c_process_expr_stmt): Call mark_exp_read even
for exprs satisfying handled_component_p.
2010-04-12 Eric Botcazou <ebotcazou@adacore.com> 2010-04-12 Eric Botcazou <ebotcazou@adacore.com>
* expr.c (categorize_ctor_elements_1): Properly count sub-elements of * expr.c (categorize_ctor_elements_1): Properly count sub-elements of
......
...@@ -8826,11 +8826,13 @@ c_process_expr_stmt (location_t loc, tree expr) ...@@ -8826,11 +8826,13 @@ c_process_expr_stmt (location_t loc, tree expr)
&& warn_unused_value) && warn_unused_value)
emit_side_effect_warnings (loc, expr); emit_side_effect_warnings (loc, expr);
if (DECL_P (expr) || handled_component_p (expr))
mark_exp_read (expr);
/* If the expression is not of a type to which we cannot assign a line /* If the expression is not of a type to which we cannot assign a line
number, wrap the thing in a no-op NOP_EXPR. */ number, wrap the thing in a no-op NOP_EXPR. */
if (DECL_P (expr) || CONSTANT_CLASS_P (expr)) if (DECL_P (expr) || CONSTANT_CLASS_P (expr))
{ {
mark_exp_read (expr);
expr = build1 (NOP_EXPR, TREE_TYPE (expr), expr); expr = build1 (NOP_EXPR, TREE_TYPE (expr), expr);
SET_EXPR_LOCATION (expr, loc); SET_EXPR_LOCATION (expr, loc);
} }
......
2010-04-12 Jakub Jelinek <jakub@redhat.com> 2010-04-12 Jakub Jelinek <jakub@redhat.com>
PR bootstrap/43699
* gcc.dg/Wunused-var-7.c: New test.
PR tree-optimization/43560 PR tree-optimization/43560
* gcc.c-torture/execute/pr43560.c: New test. * gcc.c-torture/execute/pr43560.c: New test.
......
/* { dg-do compile } */
/* { dg-options "-Wunused -W" } */
int
f1 (unsigned int x)
{
int c = ({ union { unsigned int a; int b; } u; u.a = x; u.b; });
return c;
}
void
f2 (void)
{
struct S { int i; } a;
int b[1];
a.i = 1;
a.i; /* { dg-warning "with no effect" } */
b[0] = 1;
b[0]; /* { dg-warning "with no effect" } */
}
void
f3 (void)
{
struct S { int i; } a; /* { dg-warning "set but not used" } */
int b[1]; /* { dg-warning "set but not used" } */
a.i = 1;
b[0] = 1;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment