Message ID | 20140122210410.GU8907@redhat.com |
---|---|
State | New |
Headers | show |
On Wed, 22 Jan 2014, Marek Polacek wrote: > 2014-01-22 Marek Polacek <polacek@redhat.com> > > 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. OK.
--- gcc/c/c-typeck.c.mp3 2014-01-22 18:47:36.812358319 +0100 +++ gcc/c/c-typeck.c 2014-01-22 18:45:10.298692933 +0100 @@ -4708,8 +4708,10 @@ build_conditional_expr (location_t colon { 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) --- gcc/testsuite/gcc.dg/torture/pr59891.c.mp3 2014-01-22 19:16:34.000000000 +0100 +++ gcc/testsuite/gcc.dg/torture/pr59891.c 2014-01-22 19:19:23.996129684 +0100 @@ -0,0 +1,9 @@ +/* PR c/59891 */ + +unsigned int a; + +int +main () +{ + return (0 ? a : 0) ? : 0 % 0; /* { dg-warning "division by zero" } */ +}