re PR c/54363 (ICE when compiling malformed struct initializers)
authorJakub Jelinek <jakub@redhat.com>
Fri, 24 Aug 2012 21:46:17 +0000 (23:46 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 24 Aug 2012 21:46:17 +0000 (23:46 +0200)
PR c/54363
* gimplify.c (optimize_compound_literals_in_ctor): Only recurse
if init is a CONSTRUCTOR.

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

From-SVN: r190657

gcc/ChangeLog
gcc/gimplify.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr54363.c [new file with mode: 0644]

index a51eea229bba4fd20c4dcb09ceefc286e55d63f8..f160b8fa5c378e31a73414530d6fa4a9089235da 100644 (file)
@@ -1,3 +1,9 @@
+2012-08-24  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c/54363
+       * gimplify.c (optimize_compound_literals_in_ctor): Only recurse
+       if init is a CONSTRUCTOR.
+
 2012-08-24  Steven Bosscher  <steven@gcc.gnu.org>
 
        * tree-ssa-live.c (dump_var_map): Do not dump the partition
index ed2474fe390844581772696fc715878e95c2ee15..27930277c9c597197edd560adb4167482e835780 100644 (file)
@@ -3857,7 +3857,8 @@ optimize_compound_literals_in_ctor (tree orig_ctor)
 
          if (!TREE_ADDRESSABLE (value)
              && !TREE_ADDRESSABLE (decl)
-             && init)
+             && init
+             && TREE_CODE (init) == CONSTRUCTOR)
            newval = optimize_compound_literals_in_ctor (init);
        }
       if (newval == value)
index 6fa07551138a1991aada483c79f30fe866e5f5d6..eeb62dc03a92d6107f02919d430daa279d82d205 100644 (file)
@@ -1,5 +1,8 @@
 2012-08-24  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c/54363
+       * gcc.dg/pr54363.c: New test.
+
        PR c/54355
        * gcc.dg/pr54355.c: New test.
 
diff --git a/gcc/testsuite/gcc.dg/pr54363.c b/gcc/testsuite/gcc.dg/pr54363.c
new file mode 100644 (file)
index 0000000..aea0f90
--- /dev/null
@@ -0,0 +1,12 @@
+/* PR c/54363 */
+/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
+
+struct S { char **a; };
+
+void
+test (void)
+{
+  struct S b = { .a = (char **) { "a", "b" } }; /* { dg-warning "(initialization|excess elements)" } */
+  struct S c = { .a = (char *[]) { "a", "b" } };
+}