diff options
author | Jakub Jelinek <jakub@redhat.com> | 2010-04-12 15:27:07 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2010-04-12 15:27:07 +0200 |
commit | fa8351f8d807ec9cde27984171670438295bc7b4 (patch) | |
tree | ce69281cf285db8a82e42170e80479229135cc7d /gcc | |
parent | f101882ada10af2b1b682e56f7a52c248ed6eef5 (diff) | |
download | gcc-fa8351f8d807ec9cde27984171670438295bc7b4.zip gcc-fa8351f8d807ec9cde27984171670438295bc7b4.tar.gz gcc-fa8351f8d807ec9cde27984171670438295bc7b4.tar.bz2 |
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
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/c-typeck.c | 4 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 3 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/Wunused-var-7.c | 29 |
4 files changed, 41 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 0d4284c..88c9903 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +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> * expr.c (categorize_ctor_elements_1): Properly count sub-elements of diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c index 2296cbe..681c0e4 100644 --- a/gcc/c-typeck.c +++ b/gcc/c-typeck.c @@ -8826,11 +8826,13 @@ c_process_expr_stmt (location_t loc, tree expr) && warn_unused_value) 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 number, wrap the thing in a no-op NOP_EXPR. */ if (DECL_P (expr) || CONSTANT_CLASS_P (expr)) { - mark_exp_read (expr); expr = build1 (NOP_EXPR, TREE_TYPE (expr), expr); SET_EXPR_LOCATION (expr, loc); } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index fe70fb4..642f085 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2010-04-12 Jakub Jelinek <jakub@redhat.com> + PR bootstrap/43699 + * gcc.dg/Wunused-var-7.c: New test. + PR tree-optimization/43560 * gcc.c-torture/execute/pr43560.c: New test. diff --git a/gcc/testsuite/gcc.dg/Wunused-var-7.c b/gcc/testsuite/gcc.dg/Wunused-var-7.c new file mode 100644 index 0000000..e82e708 --- /dev/null +++ b/gcc/testsuite/gcc.dg/Wunused-var-7.c @@ -0,0 +1,29 @@ +/* { 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; +} |