From db1ae94f252a869aaadda3f5a13139b9ed2ec327 Mon Sep 17 00:00:00 2001 From: jason Date: Thu, 11 Jun 2015 15:45:08 +0000 Subject: [PATCH] PR c++/66445 * constexpr.c (potential_constant_expression_1): Handle a DECL_EXPR of TYPE_DECL. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@224382 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/ChangeLog | 4 ++++ gcc/cp/constexpr.c | 5 +++++ gcc/testsuite/g++.dg/ext/stmtexpr18.C | 7 +++++++ 3 files changed, 16 insertions(+) create mode 100644 gcc/testsuite/g++.dg/ext/stmtexpr18.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index b6fdc107f6ee..23c8deb22838 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2015-06-11 Jason Merrill + PR c++/66445 + * constexpr.c (potential_constant_expression_1): Handle a + DECL_EXPR of TYPE_DECL. + PR c++/66450 * constexpr.c (cxx_eval_store_expression): Avoid messing up outer ctx->ctor. diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c index af6b39ecaf50..5dc59a47a88a 100644 --- a/gcc/cp/constexpr.c +++ b/gcc/cp/constexpr.c @@ -4462,6 +4462,11 @@ potential_constant_expression_1 (tree t, bool want_rval, bool strict, } return false; + case TYPE_DECL: + case TAG_DEFN: + /* We can see these in statement-expressions. */ + return true; + default: if (objc_is_property_ref (t)) return false; diff --git a/gcc/testsuite/g++.dg/ext/stmtexpr18.C b/gcc/testsuite/g++.dg/ext/stmtexpr18.C new file mode 100644 index 000000000000..d9b99bfd2653 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/stmtexpr18.C @@ -0,0 +1,7 @@ +// PR c++/66445 +// { dg-options "" } + +template void foo () +{ + int a = ({ struct A{} b; 42; }); +} -- 2.47.3