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++/64701 (ICE with statement-expression)


The constexpr expansion code doesn't understand the C++ front end statement tree codes; for expanding a constexpr call it expects the gimplified form. For now let's not bother trying to expand a statement-expression.

Tested x86_64-pc-linux-gnu, applying to trunk.
commit e01d0162df7b21bb26449e912618a513ecbe18b0
Author: Jason Merrill <jason@redhat.com>
Date:   Wed Jan 21 16:44:24 2015 -0500

    	PR c++/64701
    	* constexpr.c (maybe_constant_value): Just hand back STATEMENT_LIST.

diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c
index 7853d37..e3e838e 100644
--- a/gcc/cp/constexpr.c
+++ b/gcc/cp/constexpr.c
@@ -3609,6 +3609,8 @@ maybe_constant_value (tree t, tree decl)
   tree r;
 
   if (instantiation_dependent_expression_p (t)
+      /* We can't deal with statements until they've been lowered.  */
+      || TREE_CODE (t) == STATEMENT_LIST
       || type_unknown_p (t)
       || BRACE_ENCLOSED_INITIALIZER_P (t)
       || !potential_constant_expression (t))
diff --git a/gcc/testsuite/g++.dg/ext/stmtexpr17.C b/gcc/testsuite/g++.dg/ext/stmtexpr17.C
new file mode 100644
index 0000000..c1640e4
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ext/stmtexpr17.C
@@ -0,0 +1,9 @@
+// PR c++/64701
+// { dg-options "" }
+
+enum { A };
+void
+foo ()
+{
+  int x = ({ do {} while (0); A; });
+}

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