This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

C++ PATCH for c++/66445 (ICE with type definition in statement-expression)


The testcase in the PR uses a lambda, but the issue affects local classes as well. A simple case of a missing 'case'.

Tested x86_64-pc-linux-gnu, applying to trunk and 5.
commit 65488b9842de11454371c9d75652f58cab3465d4
Author: Jason Merrill <jason@redhat.com>
Date:   Thu Jun 11 09:51:19 2015 -0400

    	PR c++/66445
    	* constexpr.c (potential_constant_expression_1): Handle a
    	DECL_EXPR of TYPE_DECL.

diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c
index af6b39e..5dc59a4 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 0000000..d9b99bf
--- /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; });
+}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]