From: Jakub Jelinek Date: Wed, 19 Dec 2018 08:11:40 +0000 (+0100) Subject: re PR c++/87934 (struct with NSDMI of enum makes initialization a non-constant expres... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=35d87f01947ab873477d72380b84d8b70659b541;p=gcc.git re PR c++/87934 (struct with NSDMI of enum makes initialization a non-constant expression) PR c++/87934 * constexpr.c (cxx_eval_constant_expression) : Do re-process TREE_CONSTANT CONSTRUCTORs if they aren't reduced constant expressions. * g++.dg/cpp0x/constexpr-87934.C: New test. From-SVN: r267253 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 433793f186f..b2360d54354 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2018-12-19 Jakub Jelinek + + PR c++/87934 + * constexpr.c (cxx_eval_constant_expression) : Do + re-process TREE_CONSTANT CONSTRUCTORs if they aren't reduced constant + expressions. + 2018-12-19 Alexandre Oliva PR c++/87012 diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c index f8049468c22..79df70e67a1 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 a0d7a499342..13fc179cbfe 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-12-19 Jakub Jelinek + + PR c++/87934 + * g++.dg/cpp0x/constexpr-87934.C: New test. + 2018-12-19 Alexandre Oliva 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 00000000000..32eb220d1e9 --- /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{};