[Bug c/63567] Linux kernel build error due to non-static initializers
mpolacek at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Sat Oct 18 18:30:00 GMT 2014
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63567
--- Comment #10 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Thanks. This fixes it (I need to write a proper testcase and test it).
2014-10-18 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.
diff --git gcc/c/c-typeck.c gcc/c/c-typeck.c
index 0dd3366..ee874da 100644
--- gcc/c/c-typeck.c
+++ gcc/c/c-typeck.c
@@ -8251,11 +8251,14 @@ output_init_element (location_t loc, tree value, tree
origtype,
value = array_to_pointer_conversion (input_location, value);
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
duration with compound literals (which are then treated just as
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);
value = DECL_INITIAL (decl);
}
More information about the Gcc-bugs
mailing list