]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
PR c++/66445
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 11 Jun 2015 15:45:08 +0000 (15:45 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 11 Jun 2015 15:45:08 +0000 (15:45 +0000)
* 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
gcc/cp/constexpr.c
gcc/testsuite/g++.dg/ext/stmtexpr18.C [new file with mode: 0644]

index b6fdc107f6ee8bab04d8a4e5ea851b36f6a5dbda..23c8deb2283889b93f201a98499d129564d4544b 100644 (file)
@@ -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.
index af6b39ecaf50c6b0721dc46764ede054e257f0d6..5dc59a47a88a524335da3f8d2453f7cb386b79fe 100644 (file)
@@ -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 (file)
index 0000000..d9b99bf
--- /dev/null
@@ -0,0 +1,7 @@
+// PR c++/66445
+// { dg-options "" }
+
+template <typename> void foo ()
+{
+  int a = ({ struct A{} b; 42; });
+}