Commit 4435bb92 by Marek Polacek Committed by Marek Polacek

re PR c/63567 (Linux kernel build error due to non-static initializers)

	PR c/63567
	* c-typeck.c (output_init_element): Allow initializing objects with
	static storage duration with compound literals even in C99 and add
	pedwarn for it.

	* gcc.dg/pr63567-3.c: New test.
	* gcc.dg/pr63567-4.c: New test.

From-SVN: r216440
parent f4b0b1e3
2014-10-19 Marek Polacek <polacek@redhat.com>
PR c/63567
* c-typeck.c (output_init_element): Allow initializing objects with
static storage duration with compound literals even in C99 and add
pedwarn for it.
2014-10-17 Marek Polacek <polacek@redhat.com> 2014-10-17 Marek Polacek <polacek@redhat.com>
PR c/63567 PR c/63567
......
...@@ -8251,11 +8251,14 @@ output_init_element (location_t loc, tree value, tree origtype, ...@@ -8251,11 +8251,14 @@ output_init_element (location_t loc, tree value, tree origtype,
value = array_to_pointer_conversion (input_location, value); value = array_to_pointer_conversion (input_location, value);
if (TREE_CODE (value) == COMPOUND_LITERAL_EXPR if (TREE_CODE (value) == COMPOUND_LITERAL_EXPR
&& require_constant_value && !flag_isoc99 && pending) && require_constant_value && pending)
{ {
/* As an extension, allow initializing objects with static storage /* As an extension, allow initializing objects with static storage
duration with compound literals (which are then treated just as duration with compound literals (which are then treated just as
the brace enclosed list they contain). */ the brace enclosed list they contain). */
if (flag_isoc99)
pedwarn_init (loc, OPT_Wpedantic, "initializer element is not "
"constant");
tree decl = COMPOUND_LITERAL_EXPR_DECL (value); tree decl = COMPOUND_LITERAL_EXPR_DECL (value);
value = DECL_INITIAL (decl); value = DECL_INITIAL (decl);
} }
......
2014-10-19 Marek Polacek <polacek@redhat.com>
PR c/63567
* gcc.dg/pr63567-3.c: New test.
* gcc.dg/pr63567-4.c: New test.
2014-10-19 Adhemerval Zanella <azanella@linux.vnet.ibm.com> 2014-10-19 Adhemerval Zanella <azanella@linux.vnet.ibm.com>
* gcc.dg/atomic/c11-atomic-exec-5.c * gcc.dg/atomic/c11-atomic-exec-5.c
......
/* PR c/63567 */
/* { dg-do compile } */
/* { dg-options "" } */
struct T { int i; };
struct S { struct T t; };
struct S s = { .t = { (int) { 1 } } };
/* PR c/63567 */
/* { dg-do compile } */
/* { dg-options "-Wpedantic" } */
struct T { int i; };
struct S { struct T t; };
struct S s = { .t = { (int) { 1 } } }; /* { dg-warning "initializer element is not constant" } */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment