OSDN Git Service

PR c/50179
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 26 Aug 2011 14:37:22 +0000 (14:37 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 26 Aug 2011 14:37:22 +0000 (14:37 +0000)
* 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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@178110 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/c-typeck.c
gcc/testsuite/ChangeLog
gcc/testsuite/c-c++-common/Wunused-var-14.c [new file with mode: 0644]

index dd737a1..e822ca7 100644 (file)
@@ -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
index bd932db..1f08031 100644 (file)
@@ -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
index 96d4904..04b7e1e 100644 (file)
@@ -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 (file)
index 0000000..389feba
--- /dev/null
@@ -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; });
+}