]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c/53418 (ICE at gimplify.c:7773)
authorJoseph Myers <joseph@codesourcery.com>
Mon, 21 May 2012 20:12:05 +0000 (21:12 +0100)
committerJoseph Myers <jsm28@gcc.gnu.org>
Mon, 21 May 2012 20:12:05 +0000 (21:12 +0100)
PR c/53418
* c-typeck.c (build_conditional_expr): Remove C_MAYBE_CONST_EXPR
from folded operands before wrapping another around the
conditional expression.

testsuite:
* gcc.c-torture/compile/pr53418-1.c,
gcc.c-torture/compile/pr53418-2.c: New tests.

From-SVN: r187736

gcc/ChangeLog
gcc/c-typeck.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/pr53418-1.c [new file with mode: 0644]
gcc/testsuite/gcc.c-torture/compile/pr53418-2.c [new file with mode: 0644]

index 89d9a2f44042f4915c718528cf7b21ed87d389f7..ca2386388a22fae1e07b173e8b26afee5c5aaa1d 100644 (file)
@@ -1,3 +1,10 @@
+2012-05-21  Joseph Myers  <joseph@codesourcery.com>
+
+       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-05-21  H.J. Lu  <hongjiu.lu@intel.com>
 
        Backport from mainline
index cd68a05a6cf2d2f4ef68f303e7d66f363803f971..22d93a041c258feae16a3e0ccc1e487297980964 100644 (file)
@@ -4315,6 +4315,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);
index bf146b83e52ff00c6df1893bb5c15008c94c88fe..dc2d3736da0cf2afe8d6608f2a7a3e9ea4f0c17a 100644 (file)
@@ -1,3 +1,9 @@
+2012-05-21  Joseph Myers  <joseph@codesourcery.com>
+
+       PR c/53418
+       * gcc.c-torture/compile/pr53418-1.c,
+       gcc.c-torture/compile/pr53418-2.c: New tests.
+
 2012-05-21  H.J. Lu  <hongjiu.lu@intel.com>
 
        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 (file)
index 0000000..721b02d
--- /dev/null
@@ -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 (file)
index 0000000..a437b6a
--- /dev/null
@@ -0,0 +1,5 @@
+void
+f (void)
+{
+  int i = (1 ? 0U / 0 : 1);
+}