Patchwork [libgcc] Fix fixed-bit.c build warning

login
register
mail settings
Submitter Georg-Johann Lay
Date Jan. 11, 2013, 12:16 p.m.
Message ID <50F00291.4040008@gcc.gnu.org>
Download mbox | patch
Permalink /patch/211319/
State New
Headers show

Comments

Georg-Johann Lay - Jan. 11, 2013, 12:16 p.m.
Georg-Johann Lay wrote:
> Variables min_high and min_low are set but not used which cases build warnings,
> fixed by this patch.

Better attach the patch...


> Build fine for i686-pc-linux-gnu and avr-unknown-none, the latter definitely
> using this code.
> 
> Ok for trunk?
> 
> Johann
> 
> 
> 	* fixed-bit.c (SATFRACT) <FROM_TYPE = 1, TO_TYPE = 4>: Only
> 	declare / set min_low, min_high if TO_MODE_UNSIGNED == 0.
> 	(SATFRACT) <FROM_TYPE = TO_TYPE = 4>: Only declare / set min_low,
> 	min_high if FROM_MODE_UNSIGNED == 0 and TO_MODE_UNSIGNED == 0.
Ian Taylor - Jan. 11, 2013, 2:15 p.m.
On Fri, Jan 11, 2013 at 4:16 AM, Georg-Johann Lay <gjl@gcc.gnu.org> wrote:
>>
>>       * fixed-bit.c (SATFRACT) <FROM_TYPE = 1, TO_TYPE = 4>: Only
>>       declare / set min_low, min_high if TO_MODE_UNSIGNED == 0.
>>       (SATFRACT) <FROM_TYPE = TO_TYPE = 4>: Only declare / set min_low,
>>       min_high if FROM_MODE_UNSIGNED == 0 and TO_MODE_UNSIGNED == 0.

This is OK.

Thanks.

Ian

Patch

Index: libgcc/fixed-bit.c
===================================================================
--- libgcc/fixed-bit.c	(revision 194964)
+++ libgcc/fixed-bit.c	(working copy)
@@ -761,11 +761,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;
@@ -812,13 +813,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
@@ -957,7 +957,7 @@  FRACT (FROM_INT_C_TYPE a)
 #endif /* defined(FRACT) && FROM_TYPE == 1 && TO_TYPE == 4  */
 
 /* Signed int -> Fixed with saturation.  */
-#if defined(SATFRACT) && defined(L_satfract) &&FROM_TYPE == 1 && TO_TYPE == 4
+#if defined(SATFRACT) && defined(L_satfract) && FROM_TYPE == 1 && TO_TYPE == 4
 TO_FIXED_C_TYPE
 SATFRACT (FROM_INT_C_TYPE a)
 {
@@ -966,8 +966,8 @@  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 min_high, min_low;
   BIG_SINT_C_TYPE stemp;
 #endif
 #if BIG_WIDTH != TO_FBITS
@@ -1008,12 +1008,7 @@  SATFRACT (FROM_INT_C_TYPE a)
   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;
-#endif
 
-#if TO_MODE_UNSIGNED == 0
   /* Signed -> Signed.  */
   if ((BIG_SINT_C_TYPE) high > (BIG_SINT_C_TYPE) max_high
       || ((BIG_SINT_C_TYPE) high == (BIG_SINT_C_TYPE) max_high