]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/40948 (ICE in lower_stmt, at gimple-low.c:408)
authorJason Merrill <jason@redhat.com>
Tue, 4 Aug 2009 02:10:05 +0000 (22:10 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Tue, 4 Aug 2009 02:10:05 +0000 (22:10 -0400)
PR c++/40948
* init.c (build_vec_init): Look through a TARGET_EXPR around a
CONSTRUCTOR.

Co-Authored-By: Jakub Jelinek <jakub@redhat.com>
From-SVN: r150394

gcc/cp/ChangeLog
gcc/cp/init.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/ext/complit12.C [new file with mode: 0644]

index a7d26a5a378e98f437be85b5eef393bebe9e5eed..48561368800de366f51e8ef8fc166efdd252c00d 100644 (file)
@@ -1,3 +1,10 @@
+2009-08-03  Jason Merrill  <jason@redhat.com>
+           Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/40948
+       * init.c (build_vec_init): Look through a TARGET_EXPR around a
+       CONSTRUCTOR.
+
 2009-07-31  Jason Merrill  <jason@redhat.com>
            Douglas Gregor  <doug.gregor@gmail.com>
 
index 3da8ab8464c88846a0254b24b230e75393ffb0d4..4462428321b00f0400f46972ed55c5c04660add0 100644 (file)
@@ -2695,6 +2695,12 @@ build_vec_init (tree base, tree maxindex, tree init,
     gcc_assert (!init);
 
   inner_elt_type = strip_array_types (type);
+
+  /* Look through the TARGET_EXPR around a compound literal.  */
+  if (init && TREE_CODE (init) == TARGET_EXPR
+      && TREE_CODE (TARGET_EXPR_INITIAL (init)) == CONSTRUCTOR)
+    init = TARGET_EXPR_INITIAL (init);
+
   if (init
       && TREE_CODE (atype) == ARRAY_TYPE
       && (from_array == 2
index 86a991e2600a49dc26e6c783a984a0cc32af72bf..26a37b1ad52a1701476cf34fcb9e5c30e689cc66 100644 (file)
@@ -1,3 +1,9 @@
+2009-08-03  Jason Merrill  <jason@redhat.com>
+           Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/40948
+       * g++.dg/ext/complit12.C: New.
+
 2009-08-03  Janis Johnson  <janis187@us.ibm.com>
 
        PR c/39902
diff --git a/gcc/testsuite/g++.dg/ext/complit12.C b/gcc/testsuite/g++.dg/ext/complit12.C
new file mode 100644 (file)
index 0000000..8105621
--- /dev/null
@@ -0,0 +1,54 @@
+// PR c++/40948
+// { dg-do run }
+// { dg-options "" }
+
+int c;
+struct M
+{
+  M () { ++c; }
+  M (const M&) { ++c; }
+  ~M () { --c; }
+};
+
+struct S
+{
+  S ();
+  M m[1];
+};
+
+S::S () : m ((M[1]) { M () })
+{
+}
+
+struct T
+{
+  T ();
+  M m[4];
+};
+
+T::T () : m ((M[4]) { M (), M (), M (), M () })
+{
+}
+
+int main ()
+{
+  {
+    M m[1] = (M[1]) { M () };
+    if (c != 1)
+      return 1;
+    M n = (M) { M () };
+    if (c != 2)
+      return 2;
+    M o[4] = (M[4]) { M (), M (), M (), M () };
+    if (c != 6)
+      return 3;
+    S s;
+    if (c != 7)
+      return 4;
+    T t;
+    if (c != 11)
+      return 5;
+  }
+  if (c != 0)
+    return 6;
+}