re PR c++/71728 (ICE with goto in statement-expression inside a condition)
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
This commit is contained in:
parent
1c4b8a0449
commit
ab3af181e6
4 changed files with 30 additions and 5 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
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>
|
2016-07-21 Richard Biener <rguenther@suse.de>
|
||||||
|
|
||||||
* vtable-class-hierarchy.c (vtv_generate_init_routine): Set
|
* vtable-class-hierarchy.c (vtv_generate_init_routine): Set
|
||||||
|
|
|
@ -5289,10 +5289,12 @@ potential_constant_expression_1 (tree t, bool want_rval, bool strict,
|
||||||
case GOTO_EXPR:
|
case GOTO_EXPR:
|
||||||
{
|
{
|
||||||
tree *target = &TREE_OPERAND (t, 0);
|
tree *target = &TREE_OPERAND (t, 0);
|
||||||
/* Gotos representing break and continue are OK; we should have
|
/* Gotos representing break and continue are OK. */
|
||||||
rejected other gotos in parsing. */
|
if (breaks (target) || continues (target))
|
||||||
gcc_assert (breaks (target) || continues (target));
|
return true;
|
||||||
return true;
|
if (flags & tf_error)
|
||||||
|
error ("%<goto%> is not a constant-expression");
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -5300,7 +5302,7 @@ potential_constant_expression_1 (tree t, bool want_rval, bool strict,
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
sorry ("unexpected AST of kind %s", get_tree_code_name (TREE_CODE (t)));
|
sorry ("unexpected AST of kind %s", get_tree_code_name (TREE_CODE (t)));
|
||||||
gcc_unreachable();
|
gcc_unreachable ();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#undef RECUR
|
#undef RECUR
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
|
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>
|
2016-07-21 James Greenhalgh <james.greenhalgh@arm.com>
|
||||||
|
|
||||||
* gcc.dg/ifcvt-2.c: Use parameter to guide if-conversion heuristics.
|
* gcc.dg/ifcvt-2.c: Use parameter to guide if-conversion heuristics.
|
||||||
|
|
11
gcc/testsuite/g++.dg/other/pr71728.C
Normal file
11
gcc/testsuite/g++.dg/other/pr71728.C
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
// PR c++/71728
|
||||||
|
// { dg-do compile }
|
||||||
|
// { dg-options "-std=gnu++14 -Wall" }
|
||||||
|
|
||||||
|
int
|
||||||
|
foo ()
|
||||||
|
{
|
||||||
|
if (({ goto test; test: 1; }) != 1)
|
||||||
|
return 1;
|
||||||
|
return 2;
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue