From 1ea3b9879b670a30e176046fc8e69b5c9e862c80 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Mon, 14 Jul 2014 01:25:31 -0400 Subject: re PR c++/58611 ([c++11] ICE with invalid constexpr constructor used in array initialization) PR c++/58611 * decl.c (check_initializer): Don't finish_compound_literal on erroneous constexpr init. From-SVN: r212506 --- gcc/cp/ChangeLog | 4 ++++ gcc/cp/decl.c | 7 ++----- gcc/testsuite/g++.dg/cpp0x/constexpr-array6.C | 15 +++++++++++++++ 3 files changed, 21 insertions(+), 5 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/constexpr-array6.C (limited to 'gcc') diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 63f68dc..2918318 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2014-07-13 Jason Merrill + PR c++/58611 + * decl.c (check_initializer): Don't finish_compound_literal + on erroneous constexpr init. + PR c++/58612 * tree.c (bot_replace): Only replace a dummy 'this' parm. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 8f829d0..9d3fbb2 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -5812,11 +5812,8 @@ check_initializer (tree decl, tree init, int flags, vec **cleanups) /* Declared constexpr, but no suitable initializer; massage init appropriately so we can pass it into store_init_value for the error. */ - if (init && BRACE_ENCLOSED_INITIALIZER_P (init)) - init = finish_compound_literal (type, init, - tf_warning_or_error); - else if (CLASS_TYPE_P (type) - && (!init || TREE_CODE (init) == TREE_LIST)) + if (CLASS_TYPE_P (type) + && (!init || TREE_CODE (init) == TREE_LIST)) { init = build_functional_cast (type, init, tf_none); if (TREE_CODE (init) == TARGET_EXPR) diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-array6.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-array6.C new file mode 100644 index 0000000..16eacdd --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-array6.C @@ -0,0 +1,15 @@ +// PR c++/58611 +// { dg-do compile { target c++11 } } + +struct A +{ + int i; + constexpr A() {} // { dg-error "A::i" } +}; + +struct B +{ + A a; +}; + +constexpr B b[] = { {} }; // { dg-error "A::A" } -- cgit v1.1