diff options
author | Jason Merrill <jason@redhat.com> | 2018-01-18 15:02:06 -0500 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2018-01-18 15:02:06 -0500 |
commit | d3a9902e523f81f07e765b2553dde7019aa098fb (patch) | |
tree | d3b9be5a9d6abd0e5eccb746e15aa9ff96fabd0f /gcc | |
parent | dac867c90a93d411f71a2ce960f61c0f637235ad (diff) | |
download | gcc-d3a9902e523f81f07e765b2553dde7019aa098fb.zip gcc-d3a9902e523f81f07e765b2553dde7019aa098fb.tar.gz gcc-d3a9902e523f81f07e765b2553dde7019aa098fb.tar.bz2 |
PR c++/82461 - constexpr list-initialized member
* constexpr.c (potential_constant_expression_1): Check
TARGET_EXPR_DIRECT_INIT_P.
From-SVN: r256860
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/constexpr.c | 3 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/constexpr-list2.C | 20 |
3 files changed, 28 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 2de9dcb..2240913 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2018-01-18 Jason Merrill <jason@redhat.com> + + PR c++/82461 - constexpr list-initialized member + * constexpr.c (potential_constant_expression_1): Check + TARGET_EXPR_DIRECT_INIT_P. + 2018-01-18 Paolo Carlini <paolo.carlini@oracle.com> PR c++/81013 diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c index 8984613..9a548d2 100644 --- a/gcc/cp/constexpr.c +++ b/gcc/cp/constexpr.c @@ -5726,7 +5726,8 @@ potential_constant_expression_1 (tree t, bool want_rval, bool strict, bool now, return RECUR (TREE_OPERAND (t, 1), want_rval); case TARGET_EXPR: - if (!literal_type_p (TREE_TYPE (t))) + if (!TARGET_EXPR_DIRECT_INIT_P (t) + && !literal_type_p (TREE_TYPE (t))) { if (flags & tf_error) { diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-list2.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-list2.C new file mode 100644 index 0000000..780a64d --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-list2.C @@ -0,0 +1,20 @@ +// PR c++/82461 +// { dg-do compile { target c++11 } } + +class A { +private: +public: + constexpr A() {} + ~A() {} +}; + +class B { +private: + A a; +public: + constexpr B() : a{} {} +// works +// constexpr B() : a() {} + + ~B() {} +}; |