From 6a3b64a24d74b084b77e5f0bbff64b0ea7b70159 Mon Sep 17 00:00:00 2001 From: jakub Date: Mon, 23 May 2011 18:03:31 +0000 Subject: [PATCH] PR c/49120 * c-decl.c (start_decl): Convert expr to void_type_node. * gcc.dg/pr49120.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_6-branch@174082 138bc75d-0d04-0410-961f-82ee72b054a4 index 4e82f28..001330c 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -1,6 +1,6 @@ /* Process declarations and variables for C compiler. Copyright (C) 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, - 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 + 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. This file is part of GCC. @@ -3948,7 +3948,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); new file mode 100644 index 0000000..1a65222 --- /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; +} -- 1.7.0.4