From 0787e2e7a766f7a358abdc88e9e6d339ec2ed30d Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Wed, 3 Nov 2010 15:13:27 -0400 Subject: [PATCH] re PR c++/46289 (ICE in build_constexpr_constructor_member_initializers, at cp/semantics.c:5513) PR c++/46289 * semantics.c (build_constexpr_constructor_member_initializers): Avoid ICE on error. From-SVN: r166270 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/semantics.c | 5 +++-- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/cpp0x/constexpr-ice3.C | 13 +++++++++++++ 4 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/constexpr-ice3.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index cac8a1a9534..7c4b0821732 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2010-11-03 Jason Merrill + + PR c++/46289 + * semantics.c (build_constexpr_constructor_member_initializers): + Avoid ICE on error. + 2010-11-02 Dodji Seketeli * cp-tree.h (enum tsubst_flags): diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 32154108107..562fab14d6b 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -5507,10 +5507,9 @@ build_constexpr_constructor_member_initializers (tree type, tree body) body = BIND_EXPR_BODY (body); if (TREE_CODE (body) == CLEANUP_POINT_EXPR) ok = build_data_member_initialization (body, &vec); - else + else if (TREE_CODE (body) == STATEMENT_LIST) { tree_stmt_iterator i; - gcc_assert (TREE_CODE (body) == STATEMENT_LIST); for (i = tsi_start (body); !tsi_end_p (i); tsi_next (&i)) { ok = build_data_member_initialization (tsi_stmt (i), &vec); @@ -5518,6 +5517,8 @@ build_constexpr_constructor_member_initializers (tree type, tree body) break; } } + else + gcc_assert (errorcount > 0); if (ok) return build_constructor (type, vec); else diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 26555d71b38..a2e1330f1fe 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2010-11-03 Jason Merrill + + PR c++/46289 + * g++.dg/cpp0x/constexpr-ice3.C: New. + 2010-11-03 Eric Botcazou * gnat.dg/opt8.ad[sb]: New test. diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-ice3.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-ice3.C new file mode 100644 index 00000000000..23903bca78d --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-ice3.C @@ -0,0 +1,13 @@ +// PR c++/46289 +// { dg-options -std=c++0x } + +struct A +{ + int i; +}; + +struct B +{ + A a; + constexpr B(): a({1,2}) { } // { dg-error "" } +};