re PR c++/87934 (struct with NSDMI of enum makes initialization a non-constant expres...
authorJakub Jelinek <jakub@redhat.com>
Wed, 19 Dec 2018 08:11:40 +0000 (09:11 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Wed, 19 Dec 2018 08:11:40 +0000 (09:11 +0100)
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

gcc/cp/ChangeLog
gcc/cp/constexpr.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/constexpr-87934.C [new file with mode: 0644]

index 433793f186f66ba5bb36b356dc76d3ea2d9f6556..b2360d54354c4d7a74aa61b2fab0859a0a729f28 100644 (file)
@@ -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
index f8049468c2233fee1f98e64c1c7e9d9b6cb84627..79df70e67a10ab7648d95864dacccc6b1755b097 100644 (file)
@@ -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.  */
index a0d7a499342d9fa57a09817defd5d5fda2967cfb..13fc179cbfeee38ba1e228e08daecfb663ab7ee7 100644 (file)
@@ -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 (file)
index 0000000..32eb220
--- /dev/null
@@ -0,0 +1,9 @@
+// PR c++/87934
+// { dg-do compile { target c++11 } }
+
+struct Foo
+{
+  enum { BAR } bar = BAR;
+};
+
+constexpr Foo foo{};