OSDN Git Service

Backported from mainline
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 3 Sep 2012 16:02:52 +0000 (16:02 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 3 Sep 2012 16:02:52 +0000 (16:02 +0000)
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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_7-branch@190898 138bc75d-0d04-0410-961f-82ee72b054a4

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

index 717055b..5dbdac7 100644 (file)
@@ -1,3 +1,12 @@
+2012-09-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-09-02  Eric Botcazou  <ebotcazou@adacore.com>
 
        PR rtl-optimization/54369
index 9249e42..a10d17e 100644 (file)
@@ -3730,7 +3730,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 3a1e2ad..a83d770 100644 (file)
@@ -1,3 +1,11 @@
+2012-09-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-08-31  Ollie Wild  <aaw@google.com>
 
        PR c++/54197
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" } };
+}