Blame SOURCES/gcc48-pr63567-2.patch

fdda51
2014-10-19  Marek Polacek  <polacek@redhat.com>
fdda51
fdda51
	PR c/63567
fdda51
	* c-typeck.c (output_init_element): Allow initializing objects with
fdda51
	static storage duration with compound literals even in C99 and add
fdda51
	pedwarn for it.
fdda51
fdda51
--- gcc/c/c-typeck.c
fdda51
+++ gcc/c/c-typeck.c
fdda51
@@ -8251,11 +8251,14 @@ output_init_element (location_t loc, tree value, tree origtype,
fdda51
     value = array_to_pointer_conversion (input_location, value);
fdda51
 
fdda51
   if (TREE_CODE (value) == COMPOUND_LITERAL_EXPR
fdda51
-      && require_constant_value && !flag_isoc99 && pending)
fdda51
+      && require_constant_value && pending)
fdda51
     {
fdda51
       /* As an extension, allow initializing objects with static storage
fdda51
 	 duration with compound literals (which are then treated just as
fdda51
 	 the brace enclosed list they contain).  */
fdda51
+      if (flag_isoc99)
fdda51
+	pedwarn_init (input_location, OPT_Wpedantic, "initializer element is not "
fdda51
+		      "constant");
fdda51
       tree decl = COMPOUND_LITERAL_EXPR_DECL (value);
fdda51
       value = DECL_INITIAL (decl);
fdda51
     }
fdda51
--- /dev/null
fdda51
+++ gcc/testsuite/gcc.dg/pr63567-3.c
fdda51
@@ -0,0 +1,7 @@
fdda51
+/* PR c/63567 */
fdda51
+/* { dg-do compile } */
fdda51
+/* { dg-options "" } */
fdda51
+
fdda51
+struct T { int i; };
fdda51
+struct S { struct T t; };
fdda51
+struct S s = { .t = { (int) { 1 } } };
fdda51
--- /dev/null
fdda51
+++ gcc/testsuite/gcc.dg/pr63567-4.c
fdda51
@@ -0,0 +1,7 @@
fdda51
+/* PR c/63567 */
fdda51
+/* { dg-do compile } */
fdda51
+/* { dg-options "-Wpedantic -std=gnu99" } */
fdda51
+
fdda51
+struct T { int i; };
fdda51
+struct S { struct T t; };
fdda51
+struct S s = { .t = { (int) { 1 } } }; /* { dg-warning "initializer element is not constant|initialization" } */