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