]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR c/49120 (bogus "value computed is not used" warning (variable-length...
authorJakub Jelinek <jakub@redhat.com>
Tue, 19 Jul 2011 12:48:50 +0000 (14:48 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 19 Jul 2011 12:48:50 +0000 (14:48 +0200)
Backport from mainline
2011-05-23  Jakub Jelinek  <jakub@redhat.com>

PR c/49120
* c-decl.c (start_decl): Convert expr to void_type_node.

* gcc.dg/pr49120.c: New test.

From-SVN: r176450

gcc/ChangeLog
gcc/c-decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr49120.c [new file with mode: 0644]

index 0ccc165125d75c07772ec45ee69aadb299bb5d83..d59d4a58ae236c2f50afb4ab2d2d619c26f6f290 100644 (file)
@@ -3,6 +3,9 @@
        Backport from mainline
        2011-05-23  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c/49120
+       * c-decl.c (start_decl): Convert expr to void_type_node.
+
        PR middle-end/48973
        * expr.c (expand_expr_real_2) <case LT_EXPR>: If do_store_flag
        failed and the comparison has a single bit signed type, use
index 9763b37ff27515f6ac410bd03b6b37d1bd1bb77f..abb4bdeee2af0143d2974c31f99b1ae6901c6949 100644 (file)
@@ -3909,7 +3909,7 @@ start_decl (struct c_declarator *declarator, struct c_declspecs *declspecs,
     return 0;
 
   if (expr)
-    add_stmt (expr);
+    add_stmt (fold_convert (void_type_node, expr));
 
   if (TREE_CODE (decl) != FUNCTION_DECL && MAIN_NAME_P (DECL_NAME (decl)))
     warning (OPT_Wmain, "%q+D is usually a function", decl);
index 5d1e7d5f3a90b7bb774f586b9e160b6a6b07b187..0778cdd96a25adcc5c55700c1eb0eab77aa1412a 100644 (file)
@@ -3,6 +3,9 @@
        Backport from mainline
        2011-05-23  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c/49120
+       * c-decl.c (start_decl): Convert expr to void_type_node.
+
        PR middle-end/48973
        * gcc.c-torture/execute/pr48973-1.c: New test.
        * gcc.c-torture/execute/pr48973-2.c: New test.
diff --git a/gcc/testsuite/gcc.dg/pr49120.c b/gcc/testsuite/gcc.dg/pr49120.c
new file mode 100644 (file)
index 0000000..1a65222
--- /dev/null
@@ -0,0 +1,11 @@
+/* PR c/49120 */
+/* { dg-do compile } */
+/* { dg-options "-Wall" } */
+
+int
+main ()
+{
+  int a = 1;
+  int c = ({ char b[a + 1]; b[0] = 0; b[0]; });
+  return c;
+}