]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c/64856 (Initializing struct not accepted in gnu99)
authorMarek Polacek <mpolacek@gcc.gnu.org>
Mon, 9 Feb 2015 21:19:02 +0000 (21:19 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Mon, 9 Feb 2015 21:19:02 +0000 (21:19 +0000)
PR c/64856
* c-typeck.c (process_init_element): Don't always wrap
COMPOUND_LITERAL_EXPR in a SAVE_EXPR in C99 mode when
initializing a range of elements.

* gcc.dg/pr64856.c: New test.

From-SVN: r220550

gcc/c/ChangeLog
gcc/c/c-typeck.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr64856.c [new file with mode: 0644]

index 4c822f4ca0988581ebc2dfc5c23f344b59c23a7d..fa5774cbea0e7b7b36c1d78a62b5bfe639fb2c38 100644 (file)
@@ -1,10 +1,17 @@
+2015-02-09  Marek Polacek  <polacek@redhat.com>
+
+       PR c/64856
+       * c-typeck.c (process_init_element): Don't always wrap
+       COMPOUND_LITERAL_EXPR in a SAVE_EXPR in C99 mode when
+       initializing a range of elements.
+
 2015-02-04  Jakub Jelinek  <jakub@redhat.com>
 
        PR c/64824
        PR c/64868
        * c-parser.c (c_parser_omp_atomic): Handle RDIV_EXPR.
 
-2015-02-02  Bruno Loff <bruno.loff@gmail.com>
+2015-02-02  Bruno Loff  <bruno.loff@gmail.com>
 
        * c-parser.c (c_parser_declspecs): Call invoke_plugin_callbacks after
        processing enum declaration.
index 65c6f7f42726885ea040dda6a136f6f8e03afe9e..a3a9c7760c72f8d39300116f9d1d3dcda730cf34 100644 (file)
@@ -8785,8 +8785,7 @@ process_init_element (location_t loc, struct c_expr value, bool implicit,
       /* If value is a compound literal and we'll be just using its
         content, don't put it into a SAVE_EXPR.  */
       if (TREE_CODE (value.value) != COMPOUND_LITERAL_EXPR
-         || !require_constant_value
-         || flag_isoc99)
+         || !require_constant_value)
        {
          tree semantic_type = NULL_TREE;
          if (TREE_CODE (value.value) == EXCESS_PRECISION_EXPR)
index 4fd039790e5d398902a4f41a3a86a00081255463..3d14e6041b802f24c262a90e31867e62260778cb 100644 (file)
@@ -1,3 +1,8 @@
+2015-02-09  Marek Polacek  <polacek@redhat.com>
+
+       PR c/64856
+       * gcc.dg/pr64856.c: New test.
+
 2015-02-09  Jakub Jelinek  <jakub@redhat.com>
 
        PR target/64979
diff --git a/gcc/testsuite/gcc.dg/pr64856.c b/gcc/testsuite/gcc.dg/pr64856.c
new file mode 100644 (file)
index 0000000..c21d95a
--- /dev/null
@@ -0,0 +1,13 @@
+/* PR c/64856 */
+/* { dg-do compile } */
+/* { dg-options "" } */
+
+struct A {
+  unsigned long b;
+};
+
+struct B {
+  struct A c[5];
+};
+
+struct B d = { .c = { [0 ... 4] = (struct A){ .b = 2 } } };