diff options
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/constexpr.c | 8 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/constexpr-100111.C | 7 |
2 files changed, 15 insertions, 0 deletions
diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c index b74bbac..0fb0ab4 100644 --- a/gcc/cp/constexpr.c +++ b/gcc/cp/constexpr.c @@ -5538,6 +5538,14 @@ cxx_eval_store_expression (const constexpr_ctx *ctx, tree t, CONSTRUCTOR_NO_CLEARING (*valp) = CONSTRUCTOR_NO_CLEARING (init); } + else if (TREE_CODE (init) == CONSTRUCTOR + && !same_type_ignoring_top_level_qualifiers_p (TREE_TYPE (init), + type)) + { + /* See above on initialization of empty bases. */ + gcc_assert (is_empty_class (TREE_TYPE (init)) && !lval); + return init; + } else *valp = init; diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-100111.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-100111.C new file mode 100644 index 0000000..446d21d --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-100111.C @@ -0,0 +1,7 @@ +// PR c++/100111 +// { dg-do compile { target c++11 } } +// { dg-options "-fno-elide-constructors" } + +struct A {}; +struct B : A { int b; constexpr B (A x) : A(x), b() {} }; +struct C { B c; constexpr C () : c({}) {} } d; |