* [C PATCH] Avoid nested C_MAYBE_CONST_EXPR in build_binary_op (PR c/48742)
@ 2011-04-26 18:41 Jakub Jelinek
2011-04-26 21:41 ` Joseph S. Myers
0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2011-04-26 18:41 UTC (permalink / raw)
To: Joseph S. Myers; +Cc: gcc-patches
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [C PATCH] Avoid nested C_MAYBE_CONST_EXPR in build_binary_op (PR c/48742)
2011-04-26 18:41 [C PATCH] Avoid nested C_MAYBE_CONST_EXPR in build_binary_op (PR c/48742) Jakub Jelinek
@ 2011-04-26 21:41 ` Joseph S. Myers
0 siblings, 0 replies; 2+ messages in thread
From: Joseph S. Myers @ 2011-04-26 21:41 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: gcc-patches
On Tue, 26 Apr 2011, Jakub Jelinek wrote:
> 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.
OK.
--
Joseph S. Myers
joseph@codesourcery.com
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-04-26 19:50 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-26 18:41 [C PATCH] Avoid nested C_MAYBE_CONST_EXPR in build_binary_op (PR c/48742) Jakub Jelinek
2011-04-26 21:41 ` Joseph S. Myers
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).