From: Jason Merrill Date: Mon, 14 Jul 2014 05:25:31 +0000 (-0400) Subject: re PR c++/58611 ([c++11] ICE with invalid constexpr constructor used in array initial... X-Git-Tag: releases/gcc-5.1.0~6359 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=1ea3b9879b670a30e176046fc8e69b5c9e862c80;p=thirdparty%2Fgcc.git 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 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 63f68dc2bb26..2918318506c1 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 8f829d09e985..9d3fbb275f6d 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 000000000000..16eacdde440f --- /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" }