re PR c++/49669 ([C++0x] Compiler crashes with "internal compiler error: in perform_m...
authorJason Merrill <jason@redhat.com>
Sat, 6 Aug 2011 04:34:29 +0000 (00:34 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Sat, 6 Aug 2011 04:34:29 +0000 (00:34 -0400)
PR c++/49669
* init.c (perform_member_init): Handle invalid array initializer.

From-SVN: r177497

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

index 3c1ad7f5959c3f15c3222de68607d46dec5ee847..964de150272d4c6aa4fa151aea30f622aa4d6e61 100644 (file)
@@ -1,5 +1,8 @@
 2011-08-05  Jason Merrill  <jason@redhat.com>
 
+       PR c++/49669
+       * init.c (perform_member_init): Handle invalid array initializer.
+
        PR c++/49988
        * semantics.c (cxx_eval_array_reference): Handle failure to
        reduce the array operand to something we can work with.
index d9e475e79de579486b33337c086d84c148f7f689..4fa627ba8c01c8b98ab9c31ce428e58472558494 100644 (file)
@@ -554,8 +554,10 @@ perform_member_init (tree member, tree init)
        {
          if (init)
            {
-             gcc_assert (TREE_CHAIN (init) == NULL_TREE);
-             init = TREE_VALUE (init);
+             if (TREE_CHAIN (init))
+               init = error_mark_node;
+             else
+               init = TREE_VALUE (init);
              if (BRACE_ENCLOSED_INITIALIZER_P (init))
                init = digest_init (type, init, tf_warning_or_error);
            }
index af49861a64b8a1d2c8ed40c7d97b906ab4bce871..9ce5d9b75f81e53506b29cdb1d144c43e1fe0c2a 100644 (file)
@@ -1,5 +1,8 @@
 2011-08-05  Jason Merrill  <jason@redhat.com>
 
+       PR c++/49669
+       * g++.dg/init/array28.C: New.
+
        PR c++/49988
        * g++.dg/cpp0x/constexpr-non-const-arg3.C: New.
 
diff --git a/gcc/testsuite/g++.dg/init/array28.C b/gcc/testsuite/g++.dg/init/array28.C
new file mode 100644 (file)
index 0000000..8cf19ba
--- /dev/null
@@ -0,0 +1,7 @@
+// PR c++/49669
+
+struct Foo { explicit Foo(int) { } };
+struct Goo {
+  Goo() : x(Foo(4), Foo(5)) { } // { dg-error "array" }
+  Foo x[2];
+};