PR c/53148
authorjsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 21 May 2012 14:42:26 +0000 (14:42 +0000)
committerjsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 21 May 2012 14:42:26 +0000 (14:42 +0000)
* 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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@187718 138bc75d-0d04-0410-961f-82ee72b054a4

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 d7bdb99..d4f6e5f 100644 (file)
@@ -1,3 +1,10 @@
+2012-05-21  Joseph Myers  <joseph@codesourcery.com>
+
+       PR c/53148
+       * c-typeck.c (build_conditional_expr): Remove C_MAYBE_CONST_EXPR
+       from folded operands before wrapping another around the
+       conditional expression.
+
 2012-05-21  Jakub Jelinek  <jakub@redhat.com>
 
        PR tree-optimization/53366
index f45d1dc..0398b75 100644 (file)
@@ -4408,6 +4408,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 1f1bcb4..718fe46 100644 (file)
@@ -1,3 +1,9 @@
+2012-05-21  Joseph Myers  <joseph@codesourcery.com>
+
+       PR c/53148
+       * gcc.c-torture/compile/pr53418-1.c,
+       gcc.c-torture/compile/pr53418-2.c: New tests.
+
 2012-05-21  Jakub Jelinek  <jakub@redhat.com>
 
        PR tree-optimization/53366
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);
+}