diff options
author | Jason Merrill <jason@redhat.com> | 2014-07-14 01:25:31 -0400 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2014-07-14 01:25:31 -0400 |
commit | 1ea3b9879b670a30e176046fc8e69b5c9e862c80 (patch) | |
tree | 69433d8f1e26db0c0b334321be08512bc44a4c77 /gcc | |
parent | 22c6ea004237e0dd3aebdfec3cbaad138bec06df (diff) | |
download | gcc-1ea3b9879b670a30e176046fc8e69b5c9e862c80.zip gcc-1ea3b9879b670a30e176046fc8e69b5c9e862c80.tar.gz gcc-1ea3b9879b670a30e176046fc8e69b5c9e862c80.tar.bz2 |
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
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/cp/decl.c | 7 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/constexpr-array6.C | 15 |
3 files changed, 21 insertions, 5 deletions
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 <jason@redhat.com> + 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<tree, va_gc> **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" } |