This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[C PATCH] Avoid nested C_MAYBE_CONST_EXPR in build_binary_op (PR c/48742)


Hi!

As discussed in the PR, build_binary_op was calling c_wrap_maybe_const
which added one C_MAYBE_CONST_EXPR to GT_EXPR operand, then the whole
GT_EXPR has been enclosed into another C_MAYBE_CONST_EXPR because
int_operands has been true.

Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux.
Ok for 4.6/trunk?

2011-04-26  Jakub Jelinek  <jakub@redhat.com>

	PR c/48742
	* c-typeck.c (build_binary_op): Don't wrap arguments if
	int_operands is true.

	* gcc.c-torture/compile/pr48742.c: New test.

--- gcc/c-typeck.c.jj	2011-04-12 09:37:56.000000000 +0200
+++ gcc/c-typeck.c	2011-04-26 17:10:35.000000000 +0200
@@ -10190,7 +10190,7 @@ build_binary_op (location_t location, en
 		warn_for_sign_compare (location, orig_op0_folded,
 				       orig_op1_folded, op0, op1,
 				       result_type, resultcode);
-	      if (!in_late_binary_op)
+	      if (!in_late_binary_op && !int_operands)
 		{
 		  if (!op0_maybe_const || TREE_CODE (op0) != INTEGER_CST)
 		    op0 = c_wrap_maybe_const (op0, !op0_maybe_const);
--- gcc/testsuite/gcc.c-torture/compile/pr48742.c.jj	2011-04-26 17:13:12.000000000 +0200
+++ gcc/testsuite/gcc.c-torture/compile/pr48742.c	2011-04-26 17:12:41.000000000 +0200
@@ -0,0 +1,15 @@
+/* PR c/48742 */
+
+void baz (int);
+
+int
+foo (void)
+{
+  return 1 / 0 > 0;
+}
+
+void
+bar (void)
+{
+  baz (1 <= 2 % (3 >> 1 > 5 / 6 == 3));
+}

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]