]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR c/54363 (ICE when compiling malformed struct initializers)
authorJakub Jelinek <jakub@redhat.com>
Wed, 3 Apr 2013 17:56:12 +0000 (19:56 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Wed, 3 Apr 2013 17:56:12 +0000 (19:56 +0200)
Backported from mainline
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.

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

From-SVN: r197443

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

index 3f20bcd1f9f4ee968deecdf6d71e6649551ad92a..641bd65aa563c01dad8cf11349022bb28b36b801 100644 (file)
@@ -1,6 +1,12 @@
 2013-04-03  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       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-05-03  Jakub Jelinek  <jakub@redhat.com>
  
        PR debug/53174
index 50cfc45ea0b0b86bea2f6644db52e100372b1029..1af6de61bc22dcf1ad9b6a6e298d71b107307e71 100644 (file)
@@ -3646,7 +3646,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 d6802836494fe9033f74fe0f22b18148fb152ec7..d51c2564e678203c366a55966bfc46d0ddf9f755 100644 (file)
@@ -1,6 +1,11 @@
 2013-04-03  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2012-08-24  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c/54363
+       * gcc.dg/pr54363.c: New test.
+
        2012-05-03  Jakub Jelinek  <jakub@redhat.com>
  
        PR debug/53174
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" } };
+}