Hi,
is this the right place to handle these TREE_CODEs and avoid the ICEs on
invalid or should we do something else/earlier?
(tested x86_64-linux)
Thanks,
Paolo.
///////////////////
Index: testsuite/g++.dg/cpp0x/pr51216.C
===================================================================
--- testsuite/g++.dg/cpp0x/pr51216.C (revision 0)
+++ testsuite/g++.dg/cpp0x/pr51216.C (revision 0)
@@ -0,0 +1,10 @@
+// PR c++/51216
+// { dg-options "-std=c++0x" }
+
+void foo()
+{
+ int i = ({ if (1) ; }); // { dg-error "ignored" }
+ int j = ({ for (;;) ; }); // { dg-error "ignored" }
+ int k = ({ while (1) ; }); // { dg-error "ignored" }
+ int l = ({ do { } while (1); }); // { dg-error "ignored" }
+}
Index: cp/semantics.c
===================================================================
--- cp/semantics.c (revision 181494)
+++ cp/semantics.c (working copy)
@@ -8178,6 +8178,10 @@ potential_constant_expression_1 (tree t, bool want
case EXPR_STMT:
case BIND_EXPR:
case TRANSACTION_EXPR:
+ case IF_STMT:
+ case DO_STMT:
+ case FOR_STMT:
+ case WHILE_STMT:
if (flags & tf_error)
error ("expression %qE is not a constant-expression", t);
return false;