From: Jakub Jelinek Date: Mon, 23 May 2011 18:02:03 +0000 (+0200) Subject: re PR c/49120 (bogus "value computed is not used" warning (variable-length array... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=0e0d82a784effdcfab26696cab66d03ed5f22300;p=gcc.git re PR c/49120 (bogus "value computed is not used" warning (variable-length array in compound statement)) PR c/49120 * c-decl.c (start_decl): Convert expr to void_type_node. * gcc.dg/pr49120.c: New test. From-SVN: r174081 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 97719219e4f..4c73adb3789 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2011-05-23 Jakub Jelinek + + PR c/49120 + * c-decl.c (start_decl): Convert expr to void_type_node. + 2011-05-23 Richard Sandiford PR rtl-optimization/48826 diff --git a/gcc/c-decl.c b/gcc/c-decl.c index 3843f7710f8..a7cc965f78f 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -3942,7 +3942,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); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 85137d00056..65a3514b44e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2011-05-23 Jakub Jelinek + + PR c/49120 + * gcc.dg/pr49120.c: New test. + 2011-05-23 H.J. Lu PR target/47315 diff --git a/gcc/testsuite/gcc.dg/pr49120.c b/gcc/testsuite/gcc.dg/pr49120.c new file mode 100644 index 00000000000..1a65222cfec --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr49120.c @@ -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; +}