Commit f34f1c87 by Marek Polacek Committed by Marek Polacek

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

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
parent 77b7a218
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> 2014-01-15 Jakub Jelinek <jakub@redhat.com>
PR c/58943 PR c/58943
......
...@@ -4708,8 +4708,10 @@ build_conditional_expr (location_t colon_loc, tree ifexp, bool ifexp_bcp, ...@@ -4708,8 +4708,10 @@ build_conditional_expr (location_t colon_loc, tree ifexp, bool ifexp_bcp,
{ {
if (int_operands) if (int_operands)
{ {
op1 = remove_c_maybe_const_expr (op1); /* Use c_fully_fold here, since C_MAYBE_CONST_EXPR might be
op2 = remove_c_maybe_const_expr (op2); 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); ret = build3 (COND_EXPR, result_type, ifexp, op1, op2);
if (int_operands) if (int_operands)
......
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> 2014-01-22 Jeff Law <law@redhat.com>
PR tree-optimization/59597 PR tree-optimization/59597
......
/* PR c/59891 */
unsigned int a;
int
main ()
{
return (0 ? a : 0) ? : 0 % 0; /* { dg-warning "division by zero" } */
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment