aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2018-12-19 09:11:40 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2018-12-19 09:11:40 +0100
commit35d87f01947ab873477d72380b84d8b70659b541 (patch)
tree1bd659fb7398aa8a5047a9eb2f910c2850b293de
parent0d3d674bcb173e8d694715c1e4fa24937cccc0f3 (diff)
downloadgcc-35d87f01947ab873477d72380b84d8b70659b541.zip
gcc-35d87f01947ab873477d72380b84d8b70659b541.tar.gz
gcc-35d87f01947ab873477d72380b84d8b70659b541.tar.bz2
re PR c++/87934 (struct with NSDMI of enum makes initialization a non-constant expression)
PR c++/87934 * constexpr.c (cxx_eval_constant_expression) <case CONSTRUCTOR>: Do re-process TREE_CONSTANT CONSTRUCTORs if they aren't reduced constant expressions. * g++.dg/cpp0x/constexpr-87934.C: New test. From-SVN: r267253
-rw-r--r--gcc/cp/ChangeLog7
-rw-r--r--gcc/cp/constexpr.c2
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/constexpr-87934.C9
4 files changed, 22 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 433793f..b2360d5 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,10 @@
+2018-12-19 Jakub Jelinek <jakub@redhat.com>
+
+ PR c++/87934
+ * constexpr.c (cxx_eval_constant_expression) <case CONSTRUCTOR>: Do
+ re-process TREE_CONSTANT CONSTRUCTORs if they aren't reduced constant
+ expressions.
+
2018-12-19 Alexandre Oliva <aoliva@redhat.com>
PR c++/87012
diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c
index f804946..79df70e 100644
--- a/gcc/cp/constexpr.c
+++ b/gcc/cp/constexpr.c
@@ -4681,7 +4681,7 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t,
break;
case CONSTRUCTOR:
- if (TREE_CONSTANT (t))
+ if (TREE_CONSTANT (t) && reduced_constant_expression_p (t))
{
/* Don't re-process a constant CONSTRUCTOR, but do fold it to
VECTOR_CST if applicable. */
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index a0d7a49..13fc179 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2018-12-19 Jakub Jelinek <jakub@redhat.com>
+
+ PR c++/87934
+ * g++.dg/cpp0x/constexpr-87934.C: New test.
+
2018-12-19 Alexandre Oliva <aoliva@redhat.com>
PR testsuite/86153
diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-87934.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-87934.C
new file mode 100644
index 0000000..32eb220
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-87934.C
@@ -0,0 +1,9 @@
+// PR c++/87934
+// { dg-do compile { target c++11 } }
+
+struct Foo
+{
+ enum { BAR } bar = BAR;
+};
+
+constexpr Foo foo{};