PR c++/68530
* constexpr.c (potential_constant_expression_1): Handle LOOP_EXPR
and GOTO_EXPR.
From-SVN: r235217
2016-04-19 Jason Merrill <jason@redhat.com>
+ PR c++/68206
+ PR c++/68530
+ * constexpr.c (potential_constant_expression_1): Handle LOOP_EXPR
+ and GOTO_EXPR.
+
* pt.c (tsubst_expr): Remove shadowing declaration.
(tsubst_pack_expansion): Add assert.
case NON_DEPENDENT_EXPR:
/* For convenience. */
case RETURN_EXPR:
+ case LOOP_EXPR:
+ case EXIT_EXPR:
return RECUR (TREE_OPERAND (t, 0), want_rval);
case TRY_FINALLY_EXPR:
case EMPTY_CLASS_EXPR:
return false;
+ case GOTO_EXPR:
+ {
+ tree *target = &TREE_OPERAND (t, 0);
+ /* Gotos representing break and continue are OK; we should have
+ rejected other gotos in parsing. */
+ gcc_assert (breaks (target) || continues (target));
+ return true;
+ }
+
default:
if (objc_is_property_ref (t))
return false;
--- /dev/null
+// PR c++/68530
+// { dg-do compile { target c++14 } }
+
+struct thing {
+ void foo() {}
+};
+
+template<typename>
+constexpr int count()
+{
+ auto item = thing {};
+ for(; (item.foo(), false);); // { dg-error "foo" }
+ return 0;
+}
+
+int main()
+{
+ static_assert( count<int>() == 0, "" ); // { dg-error "" }
+}