summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4>2012-05-21 20:12:05 +0000
committerjsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4>2012-05-21 20:12:05 +0000
commitdc37235be334ab1ad7abba558f0961e5d4a2a1ed (patch)
tree155d1fc773c88e4880d8c1e20295a3638f73c3e7
parent0644e52d9cd1db02c079c296905bc2b087a6d640 (diff)
downloadgcc-dc37235be334ab1ad7abba558f0961e5d4a2a1ed.tar.gz
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_6-branch@187736 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/c-typeck.c5
-rw-r--r--gcc/testsuite/ChangeLog6
-rw-r--r--gcc/testsuite/gcc.c-torture/compile/pr53418-1.c5
-rw-r--r--gcc/testsuite/gcc.c-torture/compile/pr53418-2.c5
5 files changed, 28 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 89d9a2f4404..ca2386388a2 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -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
diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c
index cd68a05a6cf..22d93a041c2 100644
--- a/gcc/c-typeck.c
+++ b/gcc/c-typeck.c
@@ -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);
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index bf146b83e52..dc2d3736da0 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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
index 00000000000..721b02d7878
--- /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 00000000000..a437b6a0e62
--- /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);
+}