http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53261
--- Comment #3 from Manuel López-Ibáñez <manu at gcc dot gnu.org> 2012-05-07
16:25:11 UTC ---
(In reply to comment #2)
> In general, build_range_check can return NULL_TREE. Just matter of doing:
>
> if (tem && integer_zerop (tem))
> return;
>
> like a few lines below?
I think you are right. I have launched a bootstrap+regtest with this patch:
Index: gcc/c-family/c-common.c
===================================================================
--- gcc/c-family/c-common.c (revision 187257)
+++ gcc/c-family/c-common.c (working copy)
@@ -1627,11 +1627,11 @@ warn_logical_operator (location_t locati
should be always false to get a warning. */
if (or_op)
in0_p = !in0_p;
tem = build_range_check (UNKNOWN_LOCATION, type, lhs, in0_p, low0, high0);
- if (integer_zerop (tem))
+ if (tem && integer_zerop (tem))
return;
rhs = make_range (op_right, &in1_p, &low1, &high1, &strict_overflow_p);
if (!rhs)
return;
@@ -1642,11 +1642,11 @@ warn_logical_operator (location_t locati
should be always false to get a warning. */
if (or_op)
in1_p = !in1_p;
tem = build_range_check (UNKNOWN_LOCATION, type, rhs, in1_p, low1, high1);
- if (integer_zerop (tem))
+ if (tem && integer_zerop (tem))
return;
/* If both expressions have the same operand, if we can merge the
ranges, and if the range test is always false, then warn. */
if (operand_equal_p (lhs, rhs, 0)
Could you test on hppa?
Actually, I am not sure whether "if (!tem || integer_zerop (tem))" is even
better.