diff mbox

Quash Wbool-compare warning in optabs.c

Message ID 20140819141253.GC14320@redhat.com
State New
Headers show

Commit Message

Marek Polacek Aug. 19, 2014, 2:12 p.m. UTC
On some archs, C[TL]Z_DEFINED_VALUE_AT_ZERO macros return only
true/false, so -Wbool-compare would warn.  But on e.g. mips or
aarch64 they might yield 2.  This patch casts the value to int
to quash that warning.  Dropping the "== 2" would be prettier,
but I don't want to break other archs.
The point is that -Wbool-compare should be enabled by -Wall,
and this is the last thing that prevents it.

Bootstrapped/regtested on x86_64-linux, ok for trunk?

2014-08-19  Marek Polacek  <polacek@redhat.com>

	* optabs.c (expand_ffs): Cast C[TL]Z_DEFINED_VALUE_AT_ZERO macros
	to int.


	Marek

Comments

Richard Henderson Aug. 19, 2014, 2:52 p.m. UTC | #1
On 08/19/2014 07:12 AM, Marek Polacek wrote:
> On some archs, C[TL]Z_DEFINED_VALUE_AT_ZERO macros return only
> true/false, so -Wbool-compare would warn.

Then we should fix them to return 0/1 instead.


r~
diff mbox

Patch

diff --git gcc/optabs.c gcc/optabs.c
index 60228d3..26b5603 100644
--- gcc/optabs.c
+++ gcc/optabs.c
@@ -2827,7 +2827,7 @@  expand_ffs (enum machine_mode mode, rtx op0, rtx target)
       if (!temp)
 	goto fail;
 
-      defined_at_zero = (CTZ_DEFINED_VALUE_AT_ZERO (mode, val) == 2);
+      defined_at_zero = ((int) CTZ_DEFINED_VALUE_AT_ZERO (mode, val) == 2);
     }
   else if (optab_handler (clz_optab, mode) != CODE_FOR_nothing)
     {
@@ -2836,7 +2836,7 @@  expand_ffs (enum machine_mode mode, rtx op0, rtx target)
       if (!temp)
 	goto fail;
 
-      if (CLZ_DEFINED_VALUE_AT_ZERO (mode, val) == 2)
+      if ((int) CLZ_DEFINED_VALUE_AT_ZERO (mode, val) == 2)
 	{
 	  defined_at_zero = true;
 	  val = (GET_MODE_PRECISION (mode) - 1) - val;