re PR c/59891 (ICE on invalid code (with div-by-zero) at all optimization levels on x86_64-linux-gnu)

PR c/59891
c/
	* c-typeck.c (build_conditional_expr): Call c_fully_fold instead
	of remove_c_maybe_const_expr on op1 and op2.
testsuite/
	* gcc.dg/torture/pr59891.c: New test.

From-SVN: r206944
This commit is contained in:
Marek Polacek 2014-01-22 22:15:12 +00:00 committed by Marek Polacek
parent 77b7a218bb
commit f34f1c878f
4 changed files with 24 additions and 2 deletions

View File

@ -1,3 +1,9 @@
2014-01-22 Marek Polacek <polacek@redhat.com>
PR c/59891
* c-typeck.c (build_conditional_expr): Call c_fully_fold instead
of remove_c_maybe_const_expr on op1 and op2.
2014-01-15 Jakub Jelinek <jakub@redhat.com>
PR c/58943

View File

@ -4708,8 +4708,10 @@ build_conditional_expr (location_t colon_loc, tree ifexp, bool ifexp_bcp,
{
if (int_operands)
{
op1 = remove_c_maybe_const_expr (op1);
op2 = remove_c_maybe_const_expr (op2);
/* Use c_fully_fold here, since C_MAYBE_CONST_EXPR might be
nested inside of the expression. */
op1 = c_fully_fold (op1, false, NULL);
op2 = c_fully_fold (op2, false, NULL);
}
ret = build3 (COND_EXPR, result_type, ifexp, op1, op2);
if (int_operands)

View File

@ -1,3 +1,8 @@
2014-01-22 Marek Polacek <polacek@redhat.com>
PR c/59891
* gcc.dg/torture/pr59891.c: New test.
2014-01-22 Jeff Law <law@redhat.com>
PR tree-optimization/59597

View File

@ -0,0 +1,9 @@
/* PR c/59891 */
unsigned int a;
int
main ()
{
return (0 ? a : 0) ? : 0 % 0; /* { dg-warning "division by zero" } */
}