summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/cp/ChangeLog4
-rw-r--r--gcc/cp/constexpr.c5
-rw-r--r--gcc/testsuite/g++.dg/ext/stmtexpr18.C7
3 files changed, 16 insertions, 0 deletions
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 <jason@redhat.com>
+ 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 <typename> void foo ()
+{
+ int a = ({ struct A{} b; 42; });
+}