File gcc48-pr63567.patch of Package gcc48.23509
commit 7278465e24b3d5a399ae2474f12870a91ba6af62
Author: Marek Polacek <polacek@redhat.com>
Date: Fri Oct 17 21:02:54 2014 +0000
re PR c/63567 (Linux kernel build error due to non-static initializers)
PR c/63567
* c-typeck.c (digest_init): Allow initializing objects with static
storage duration with compound literals even in C99 and add pedwarn
for it.
* gcc.dg/pr61096-1.c: Change dg-error into dg-warning.
* gcc.dg/pr63567-1.c: New test.
* gcc.dg/pr63567-2.c: New test.
From-SVN: r216416
Index: gcc/c/c-typeck.c
===================================================================
--- gcc/c/c-typeck.c (revision 235439)
+++ gcc/c/c-typeck.c (working copy)
@@ -6223,13 +6223,15 @@ digest_init (location_t init_loc, tree t
inside_init = convert (type, inside_init);
if (require_constant
- && (code == VECTOR_TYPE || !flag_isoc99)
&& TREE_CODE (inside_init) == COMPOUND_LITERAL_EXPR)
{
/* 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). Also allow this for
vectors, as we can only assign them with compound literals. */
+ if (flag_isoc99 && code != VECTOR_TYPE)
+ pedwarn_init (init_loc, OPT_Wpedantic, "initializer element "
+ "is not constant");
tree decl = COMPOUND_LITERAL_EXPR_DECL (inside_init);
inside_init = DECL_INITIAL (decl);
}