diff options
author | Jakub Jelinek <jakub@redhat.com> | 2011-08-26 16:37:22 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2011-08-26 16:37:22 +0200 |
commit | f1a89dd00ccfb6e77ecec7203f40653b53a93cff (patch) | |
tree | 413636b1ba12d92675262e9fef4b7c81c3aab4d0 /gcc | |
parent | fd3e0a33c7df8b478e10c3d4ac6af11e77aae425 (diff) | |
download | gcc-f1a89dd00ccfb6e77ecec7203f40653b53a93cff.zip gcc-f1a89dd00ccfb6e77ecec7203f40653b53a93cff.tar.gz gcc-f1a89dd00ccfb6e77ecec7203f40653b53a93cff.tar.bz2 |
re PR c/50179 (wrong "set but not used" warning)
PR c/50179
* c-typeck.c (c_process_expr_stmt): Skip over nops and
call mark_exp_read even if exprv is ADDR_EXPR.
* c-c++-common/Wunused-var-14.c: New test.
From-SVN: r178110
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/c-typeck.c | 6 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/Wunused-var-14.c | 13 |
4 files changed, 29 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index dd737a1..e822ca7 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2011-08-26 Jakub Jelinek <jakub@redhat.com> + + PR c/50179 + * c-typeck.c (c_process_expr_stmt): Skip over nops and + call mark_exp_read even if exprv is ADDR_EXPR. + 2011-08-26 Richard Sandiford <richard.sandiford@linaro.org> * df-problems.c (df_note_bb_compute): Pass uses rather than defs diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c index bd932db..1f08031 100644 --- a/gcc/c-typeck.c +++ b/gcc/c-typeck.c @@ -9109,7 +9109,11 @@ c_process_expr_stmt (location_t loc, tree expr) exprv = expr; while (TREE_CODE (exprv) == COMPOUND_EXPR) exprv = TREE_OPERAND (exprv, 1); - if (DECL_P (exprv) || handled_component_p (exprv)) + while (CONVERT_EXPR_P (exprv)) + exprv = TREE_OPERAND (exprv, 0); + if (DECL_P (exprv) + || handled_component_p (exprv) + || TREE_CODE (exprv) == ADDR_EXPR) mark_exp_read (exprv); /* If the expression is not of a type to which we cannot assign a line diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 96d4904..04b7e1e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2011-08-26 Jakub Jelinek <jakub@redhat.com> + + PR c/50179 + * c-c++-common/Wunused-var-14.c: New test. + 2011-08-26 Tom de Vries <tom@codesourcery.com> * gcc.dg/tree-ssa/ivopts-lt.c: New test. diff --git a/gcc/testsuite/c-c++-common/Wunused-var-14.c b/gcc/testsuite/c-c++-common/Wunused-var-14.c new file mode 100644 index 0000000..389feba --- /dev/null +++ b/gcc/testsuite/c-c++-common/Wunused-var-14.c @@ -0,0 +1,13 @@ +/* PR c/50179 */ +/* { dg-options "-Wunused" } */ +/* { dg-do compile } */ + +void bar (int, ...); + +char * +foo (void) +{ + bar (1, (__extension__ ({ static char b[2]; b[0] = 1; b; }))); + bar (1, ({ static char c[2]; c[0] = 1; c; })); + return ({ static char d[2]; d[0] = 1; d; }); +} |