re PR c++/64701 (internal compiler error: unexpected expression ‘<statement>’ of...
authorJason Merrill <jason@redhat.com>
Fri, 23 Jan 2015 16:29:46 +0000 (11:29 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Fri, 23 Jan 2015 16:29:46 +0000 (11:29 -0500)
PR c++/64701
* constexpr.c (maybe_constant_value): Just hand back STATEMENT_LIST.

From-SVN: r220046

gcc/cp/ChangeLog
gcc/cp/constexpr.c
gcc/testsuite/g++.dg/ext/stmtexpr17.C [new file with mode: 0644]

index b1d4965cc3977a3d70d8d38831c8043c3597b856..98bbcbd5a07ee6e057192d9acc8fc7e0a5a31865 100644 (file)
@@ -1,5 +1,8 @@
 2015-01-23  Jason Merrill  <jason@redhat.com>
 
+       PR c++/64701
+       * constexpr.c (maybe_constant_value): Just hand back STATEMENT_LIST.
+
        PR c++/64727
        * constexpr.c (cxx_eval_constant_expression): Allow for lvalue use
        of CONST_DECL.
index f144ab01d247603f5f65d1f3b494330f68ce2be7..f14342075208625fc870aa2fd479ff3045bc8ed8 100644 (file)
@@ -3454,8 +3454,18 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t,
       break;
 
     default:
-      internal_error ("unexpected expression %qE of kind %s", t,
-                     get_tree_code_name (TREE_CODE (t)));
+      if (STATEMENT_CODE_P (TREE_CODE (t)))
+       {
+         /* This function doesn't know how to deal with pre-genericize
+            statements; this can only happen with statement-expressions,
+            so for now just fail.  */
+         if (!ctx->quiet)
+           error_at (EXPR_LOCATION (t),
+                     "statement is not a constant-expression");
+       }
+      else
+       internal_error ("unexpected expression %qE of kind %s", t,
+                       get_tree_code_name (TREE_CODE (t)));
       *non_constant_p = true;
       break;
     }
diff --git a/gcc/testsuite/g++.dg/ext/stmtexpr17.C b/gcc/testsuite/g++.dg/ext/stmtexpr17.C
new file mode 100644 (file)
index 0000000..c1640e4
--- /dev/null
@@ -0,0 +1,9 @@
+// PR c++/64701
+// { dg-options "" }
+
+enum { A };
+void
+foo ()
+{
+  int x = ({ do {} while (0); A; });
+}