aboutsummaryrefslogtreecommitdiff
path: root/gcc/c
diff options
context:
space:
mode:
authorMarek Polacek <polacek@redhat.com>2014-10-19 16:47:35 +0000
committerMarek Polacek <mpolacek@gcc.gnu.org>2014-10-19 16:47:35 +0000
commit4435bb9232cf3a3ab015f7bc0f8dbe562bd8e0c8 (patch)
treeea2bf947f9fb2a51c3da0346c6c1a18b7d9ff357 /gcc/c
parentf4b0b1e3bb4dd4d89efdee99b5d032302a5f4717 (diff)
downloadgcc-4435bb9232cf3a3ab015f7bc0f8dbe562bd8e0c8.zip
gcc-4435bb9232cf3a3ab015f7bc0f8dbe562bd8e0c8.tar.gz
gcc-4435bb9232cf3a3ab015f7bc0f8dbe562bd8e0c8.tar.bz2
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
Diffstat (limited to 'gcc/c')
-rw-r--r--gcc/c/ChangeLog7
-rw-r--r--gcc/c/c-typeck.c5
2 files changed, 11 insertions, 1 deletions
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog
index 35b8dcd..397bf28 100644
--- a/gcc/c/ChangeLog
+++ b/gcc/c/ChangeLog
@@ -1,3 +1,10 @@
+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>
PR c/63567
diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c
index 0dd3366..ee874da 100644
--- a/gcc/c/c-typeck.c
+++ b/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);
}