PR c++/71728
* constexpr.c (potential_constant_expression_1) <case GOTO_EXPR>:
Replace assert with test, return false if the goto isn't break
or continue. Formatting fix.
* g++.dg/other/pr71728.C: New test.
From-SVN: r238601
+2016-07-21 Jakub Jelinek <jakub@redhat.com>
+
+ PR c++/71728
+ * constexpr.c (potential_constant_expression_1) <case GOTO_EXPR>:
+ Replace assert with test, return false if the goto isn't break
+ or continue. Formatting fix.
+
2016-07-21 Richard Biener <rguenther@suse.de>
* vtable-class-hierarchy.c (vtv_generate_init_routine): Set
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;
+ /* Gotos representing break and continue are OK. */
+ if (breaks (target) || continues (target))
+ return true;
+ if (flags & tf_error)
+ error ("%<goto%> is not a constant-expression");
+ return false;
}
default:
return false;
sorry ("unexpected AST of kind %s", get_tree_code_name (TREE_CODE (t)));
- gcc_unreachable();
+ gcc_unreachable ();
return false;
}
#undef RECUR
+2016-07-21 Jakub Jelinek <jakub@redhat.com>
+
+ PR c++/71728
+ * g++.dg/other/pr71728.C: New test.
+
2016-07-21 James Greenhalgh <james.greenhalgh@arm.com>
* gcc.dg/ifcvt-2.c: Use parameter to guide if-conversion heuristics.
--- /dev/null
+// PR c++/71728
+// { dg-do compile }
+// { dg-options "-std=gnu++14 -Wall" }
+
+int
+foo ()
+{
+ if (({ goto test; test: 1; }) != 1)
+ return 1;
+ return 2;
+}