From 133bc698cb8f42e3655fc68fee19c62fd18d98f7 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Thu, 11 Jun 2015 11:45:08 -0400 Subject: [PATCH] re PR c++/66445 (ICE with lambda in stmt expression in a template) PR c++/66445 * constexpr.c (potential_constant_expression_1): Handle a DECL_EXPR of TYPE_DECL. From-SVN: r224382 --- 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 b6fdc107f6e..23c8deb2283 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 af6b39ecaf5..5dc59a47a88 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 00000000000..d9b99bfd265 --- /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.30.2