diff mbox

[libgcc] Fix build warnings in fixed-bit.c

Message ID 4BB8A55A-A09F-4998-BDCF-22B255FF8984@codesourcery.com
State New
Headers show

Commit Message

Iain Sandoe June 15, 2012, 1:31 p.m. UTC
Hi,

When building for, say, mips-linux-gnu, the build of objects from fixed-bit.c produces a lot of "set but not used" warnings for min_high & min_low.

looking at the code, these appear to be genuine.
Fixed as below.

OK for trunk?
Iain

libgcc:
	* fixed-bit.c (SATFRACT): Adjust declarations and init for
	min_high, min_low.

Comments

Iain Sandoe June 22, 2012, 12:35 p.m. UTC | #1
ping.

On 15 Jun 2012, at 14:31, Iain Sandoe wrote:

> Hi,
> 
> When building for, say, mips-linux-gnu, the build of objects from fixed-bit.c produces a lot of "set but not used" warnings for min_high & min_low.
> 
> looking at the code, these appear to be genuine.
> Fixed as below.
> 
> OK for trunk?
> Iain
> 
> libgcc:
> 	* fixed-bit.c (SATFRACT): Adjust declarations and init for
> 	min_high, min_low.
> 
> 
> Index: libgcc/fixed-bit.c
> ===================================================================
> --- libgcc/fixed-bit.c	(revision 188657)
> +++ libgcc/fixed-bit.c	(working copy)
> @@ -768,11 +768,12 @@ SATFRACT (FROM_FIXED_C_TYPE a)
> #if FROM_MODE_UNSIGNED == 0
>   BIG_SINT_C_TYPE high, low;
>   BIG_SINT_C_TYPE max_high, max_low;
> +# if TO_MODE_UNSIGNED == 0
>   BIG_SINT_C_TYPE min_high, min_low;
> +# endif
> #else
>   BIG_UINT_C_TYPE high, low;
>   BIG_UINT_C_TYPE max_high, max_low;
> -  BIG_UINT_C_TYPE min_high, min_low;
> #endif
> #if TO_FBITS > FROM_FBITS
>   BIG_UINT_C_TYPE utemp;
> @@ -819,13 +820,12 @@ SATFRACT (FROM_FIXED_C_TYPE a)
> #endif
> 
> #if TO_MODE_UNSIGNED == 0
> -  min_high = -1;
>   stemp = (BIG_SINT_C_TYPE)1 << (BIG_WIDTH - 1);
>   stemp = stemp >> (BIG_WIDTH - 1 - TO_I_F_BITS);
> +# if FROM_MODE_UNSIGNED == 0
> +  min_high = -1;
>   min_low = stemp;
> -#else
> -  min_high = 0;
> -  min_low = 0;
> +# endif
> #endif
> 
> #if FROM_MODE_UNSIGNED == 0 && TO_MODE_UNSIGNED == 0
> @@ -973,9 +973,9 @@ SATFRACT (FROM_INT_C_TYPE a)
>   FROM_INT_C_TYPE x = a;
>   BIG_SINT_C_TYPE high, low;
>   BIG_SINT_C_TYPE max_high, max_low;
> -  BIG_SINT_C_TYPE min_high, min_low;
> #if TO_MODE_UNSIGNED == 0
>   BIG_SINT_C_TYPE stemp;
> +  BIG_SINT_C_TYPE min_low, min_high;
> #endif
> #if BIG_WIDTH != TO_FBITS
>   BIG_UINT_C_TYPE utemp;
> @@ -1011,13 +1011,10 @@ SATFRACT (FROM_INT_C_TYPE a)
> #endif
> 
> #if TO_MODE_UNSIGNED == 0
> -  min_high = -1;
>   stemp = (BIG_SINT_C_TYPE)1 << (BIG_WIDTH - 1);
>   stemp = stemp >> (BIG_WIDTH - 1 - TO_I_F_BITS);
>   min_low = stemp;
> -#else
> -  min_high = 0;
> -  min_low = 0;
> +  min_high = -1;
> #endif
> 
> #if TO_MODE_UNSIGNED == 0
>
Ian Lance Taylor June 22, 2012, 1:31 p.m. UTC | #2
On 15 Jun 2012, at 14:31, Iain Sandoe wrote:

> When building for, say, mips-linux-gnu, the build of objects from fixed-bit.c produces a lot of "set but not used" warnings for min_high & min_low.
> 
> looking at the code, these appear to be genuine.
> Fixed as below.
> 
> OK for trunk?
> Iain
> 
> libgcc:
> 	* fixed-bit.c (SATFRACT): Adjust declarations and init for
> 	min_high, min_low.
> 
> 
> Index: libgcc/fixed-bit.c
> ===================================================================
> --- libgcc/fixed-bit.c	(revision 188657)
> +++ libgcc/fixed-bit.c	(working copy)
> @@ -768,11 +768,12 @@ SATFRACT (FROM_FIXED_C_TYPE a)
> #if FROM_MODE_UNSIGNED == 0
>   BIG_SINT_C_TYPE high, low;
>   BIG_SINT_C_TYPE max_high, max_low;
> +# if TO_MODE_UNSIGNED == 0
>   BIG_SINT_C_TYPE min_high, min_low;
> +# endif
> #else
>   BIG_UINT_C_TYPE high, low;
>   BIG_UINT_C_TYPE max_high, max_low;
> -  BIG_UINT_C_TYPE min_high, min_low;
> #endif
> #if TO_FBITS > FROM_FBITS
>   BIG_UINT_C_TYPE utemp;
> @@ -819,13 +820,12 @@ SATFRACT (FROM_FIXED_C_TYPE a)
> #endif
> 
> #if TO_MODE_UNSIGNED == 0
> -  min_high = -1;
>   stemp = (BIG_SINT_C_TYPE)1 << (BIG_WIDTH - 1);
>   stemp = stemp >> (BIG_WIDTH - 1 - TO_I_F_BITS);
> +# if FROM_MODE_UNSIGNED == 0
> +  min_high = -1;
>   min_low = stemp;
> -#else
> -  min_high = 0;
> -  min_low = 0;
> +# endif
> #endif

As far as I can see, there is no need to move the min_high line.  You
should just move the four lines from the setting of min_high to the
setting of min_low into the 
#if FROM_MODE_UNSIGNED == 0 && TO_MODE_UNSIGNED == 0
section just below.  For simplicity you should move the declarations of
min_high, min_low, and stemp into a section with the same #if.


> #if FROM_MODE_UNSIGNED == 0 && TO_MODE_UNSIGNED == 0
> @@ -973,9 +973,9 @@ SATFRACT (FROM_INT_C_TYPE a)
>   FROM_INT_C_TYPE x = a;
>   BIG_SINT_C_TYPE high, low;
>   BIG_SINT_C_TYPE max_high, max_low;
> -  BIG_SINT_C_TYPE min_high, min_low;
> #if TO_MODE_UNSIGNED == 0
>   BIG_SINT_C_TYPE stemp;
> +  BIG_SINT_C_TYPE min_low, min_high;
> #endif
> #if BIG_WIDTH != TO_FBITS
>   BIG_UINT_C_TYPE utemp;
> @@ -1011,13 +1011,10 @@ SATFRACT (FROM_INT_C_TYPE a)
> #endif
> 
> #if TO_MODE_UNSIGNED == 0
> -  min_high = -1;
>   stemp = (BIG_SINT_C_TYPE)1 << (BIG_WIDTH - 1);
>   stemp = stemp >> (BIG_WIDTH - 1 - TO_I_F_BITS);
>   min_low = stemp;
> -#else
> -  min_high = 0;
> -  min_low = 0;
> +  min_high = -1;
> #endif

Don't move the assignment to min_high, just drop the #else part.

Ian
diff mbox

Patch

Index: libgcc/fixed-bit.c
===================================================================
--- libgcc/fixed-bit.c	(revision 188657)
+++ libgcc/fixed-bit.c	(working copy)
@@ -768,11 +768,12 @@  SATFRACT (FROM_FIXED_C_TYPE a)
 #if FROM_MODE_UNSIGNED == 0
   BIG_SINT_C_TYPE high, low;
   BIG_SINT_C_TYPE max_high, max_low;
+# if TO_MODE_UNSIGNED == 0
   BIG_SINT_C_TYPE min_high, min_low;
+# endif
 #else
   BIG_UINT_C_TYPE high, low;
   BIG_UINT_C_TYPE max_high, max_low;
-  BIG_UINT_C_TYPE min_high, min_low;
 #endif
 #if TO_FBITS > FROM_FBITS
   BIG_UINT_C_TYPE utemp;
@@ -819,13 +820,12 @@  SATFRACT (FROM_FIXED_C_TYPE a)
 #endif
 
 #if TO_MODE_UNSIGNED == 0
-  min_high = -1;
   stemp = (BIG_SINT_C_TYPE)1 << (BIG_WIDTH - 1);
   stemp = stemp >> (BIG_WIDTH - 1 - TO_I_F_BITS);
+# if FROM_MODE_UNSIGNED == 0
+  min_high = -1;
   min_low = stemp;
-#else
-  min_high = 0;
-  min_low = 0;
+# endif
 #endif
 
 #if FROM_MODE_UNSIGNED == 0 && TO_MODE_UNSIGNED == 0
@@ -973,9 +973,9 @@  SATFRACT (FROM_INT_C_TYPE a)
   FROM_INT_C_TYPE x = a;
   BIG_SINT_C_TYPE high, low;
   BIG_SINT_C_TYPE max_high, max_low;
-  BIG_SINT_C_TYPE min_high, min_low;
 #if TO_MODE_UNSIGNED == 0
   BIG_SINT_C_TYPE stemp;
+  BIG_SINT_C_TYPE min_low, min_high;
 #endif
 #if BIG_WIDTH != TO_FBITS
   BIG_UINT_C_TYPE utemp;
@@ -1011,13 +1011,10 @@  SATFRACT (FROM_INT_C_TYPE a)
 #endif
 
 #if TO_MODE_UNSIGNED == 0
-  min_high = -1;
   stemp = (BIG_SINT_C_TYPE)1 << (BIG_WIDTH - 1);
   stemp = stemp >> (BIG_WIDTH - 1 - TO_I_F_BITS);
   min_low = stemp;
-#else
-  min_high = 0;
-  min_low = 0;
+  min_high = -1;
 #endif
 
 #if TO_MODE_UNSIGNED == 0