73 lines
2.0 KiB
Diff
73 lines
2.0 KiB
Diff
From fceecb5f37d65944c822bd172cde89e670669d49 Mon Sep 17 00:00:00 2001
|
|
From: Jason Merrill <jason@redhat.com>
|
|
Date: Mon, 29 Jan 2018 15:58:36 -0500
|
|
Subject: [PATCH] PR c++/82461 - constexpr list-initialized member
|
|
|
|
* constexpr.c (potential_constant_expression_1): Check
|
|
TARGET_EXPR_DIRECT_INIT_P.
|
|
|
|
From-SVN: r257164
|
|
---
|
|
gcc/cp/ChangeLog | 5 +++++
|
|
gcc/cp/constexpr.c | 3 ++-
|
|
gcc/testsuite/g++.dg/cpp0x/constexpr-list2.C | 20 ++++++++++++++++++++
|
|
3 files changed, 27 insertions(+), 1 deletion(-)
|
|
create mode 100644 gcc/testsuite/g++.dg/cpp0x/constexpr-list2.C
|
|
|
|
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
|
|
index 6aa0075b5..801d8cee3 100644
|
|
--- a/gcc/cp/ChangeLog
|
|
+++ b/gcc/cp/ChangeLog
|
|
@@ -1,3 +1,8 @@
|
|
+2018-01-29 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-02-15 Jason Merrill <jason@redhat.com>
|
|
|
|
PR c++/83227 - C++17 ICE with init-list derived-to-base conversion.
|
|
diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c
|
|
index 9082230b9..0d294ca49 100644
|
|
--- a/gcc/cp/constexpr.c
|
|
+++ b/gcc/cp/constexpr.c
|
|
@@ -5627,7 +5627,8 @@ potential_constant_expression_1 (tree t, bool want_rval, bool strict,
|
|
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 000000000..780a64dbb
|
|
--- /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() {}
|
|
+};
|
|
--
|
|
2.27.0
|
|
|