From dd56ca9f1c8d3a236474453de81433a7c911f71b Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Sat, 6 Aug 2011 00:34:29 -0400 Subject: [PATCH] re PR c++/49669 ([C++0x] Compiler crashes with "internal compiler error: in perform_member_init, at cp/init.c:530") PR c++/49669 * init.c (perform_member_init): Handle invalid array initializer. From-SVN: r177497 --- gcc/cp/ChangeLog | 3 +++ gcc/cp/init.c | 6 ++++-- gcc/testsuite/ChangeLog | 3 +++ gcc/testsuite/g++.dg/init/array28.C | 7 +++++++ 4 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.dg/init/array28.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 3c1ad7f5959..964de150272 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,8 @@ 2011-08-05 Jason Merrill + 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. diff --git a/gcc/cp/init.c b/gcc/cp/init.c index d9e475e79de..4fa627ba8c0 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -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); } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index af49861a64b..9ce5d9b75f8 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2011-08-05 Jason Merrill + 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 index 00000000000..8cf19ba4331 --- /dev/null +++ b/gcc/testsuite/g++.dg/init/array28.C @@ -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]; +}; -- 2.30.2