From: Richard Guenther Date: Wed, 20 Jun 2012 14:39:36 +0000 (+0000) Subject: backport: re PR c/53418 (ICE at gimplify.c:7773) X-Git-Tag: releases/gcc-4.5.4~56 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6bc37cd7e6f91f7a404551c07afb073285e4d237;p=thirdparty%2Fgcc.git backport: re PR c/53418 (ICE at gimplify.c:7773) 2012-06-20 Richard Guenther Backport from mainline 2012-05-21 Joseph Myers PR c/53418 * c-typeck.c (build_conditional_expr): Remove C_MAYBE_CONST_EXPR from folded operands before wrapping another around the conditional expression. * gcc.c-torture/compile/pr53418-1.c, gcc.c-torture/compile/pr53418-2.c: New tests. From-SVN: r188837 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 4ea22dc71a02..ce6d65059473 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,13 @@ +2012-06-20 Richard Guenther + + Backport from mainline + 2012-05-21 Joseph Myers + + PR c/53418 + * c-typeck.c (build_conditional_expr): Remove C_MAYBE_CONST_EXPR + from folded operands before wrapping another around the + conditional expression. + 2012-06-20 Richard Guenther Backport from mainline diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c index 66b95127aba5..95c0353d20e7 100644 --- a/gcc/c-typeck.c +++ b/gcc/c-typeck.c @@ -4219,6 +4219,11 @@ build_conditional_expr (location_t colon_loc, tree ifexp, bool ifexp_bcp, ret = fold_build3_loc (colon_loc, COND_EXPR, result_type, ifexp, op1, op2); else { + if (int_operands) + { + op1 = remove_c_maybe_const_expr (op1); + op2 = remove_c_maybe_const_expr (op2); + } ret = build3 (COND_EXPR, result_type, ifexp, op1, op2); if (int_operands) ret = note_integer_operands (ret); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d682c613034e..b10fd95ef164 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,12 @@ +2012-06-20 Richard Guenther + + Backport from mainline + 2012-05-21 Joseph Myers + + PR c/53418 + * gcc.c-torture/compile/pr53418-1.c, + gcc.c-torture/compile/pr53418-2.c: New tests. + 2012-06-20 Richard Guenther Backport from mainline diff --git a/gcc/testsuite/gcc.c-torture/compile/pr53418-1.c b/gcc/testsuite/gcc.c-torture/compile/pr53418-1.c new file mode 100644 index 000000000000..721b02d7878d --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr53418-1.c @@ -0,0 +1,5 @@ +void +f (void) +{ + int i = (0 ? 1 : 0U / 0); +} diff --git a/gcc/testsuite/gcc.c-torture/compile/pr53418-2.c b/gcc/testsuite/gcc.c-torture/compile/pr53418-2.c new file mode 100644 index 000000000000..a437b6a0e629 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr53418-2.c @@ -0,0 +1,5 @@ +void +f (void) +{ + int i = (1 ? 0U / 0 : 1); +}