Small change in valCastLiteral. I think this is a BUG in GCC convertion of
authorsandeep <sandeep@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sat, 10 Nov 2001 06:39:13 +0000 (06:39 +0000)
committersandeep <sandeep@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sat, 10 Nov 2001 06:39:13 +0000 (06:39 +0000)
float to short was screwing up .

git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@1551 4a8a32a2-be11-0410-ad9d-d568d2c75423

src/SDCCval.c

index c61a6c8c19af9525e8c2412ef7a9ba2692ea919d..8d65e07fb5d6e64e999ead39c2080ebf4b080e33 100644 (file)
@@ -1414,34 +1414,30 @@ valCastLiteral (sym_link * dtype, double fval)
   SPEC_SCLS (val->etype) = S_LITERAL;
   /* if it is not a specifier then we can assume that */
   /* it will be an unsigned long                      */
-  if (!IS_SPEC (val->type))
-    {
+  if (!IS_SPEC (val->type)) {
       SPEC_CVAL (val->etype).v_ulong = (unsigned long) fval;
       return val;
-    }
+  }
 
   if (SPEC_NOUN (val->etype) == V_FLOAT)
-    SPEC_CVAL (val->etype).v_float = fval;
-  else
-    {
-      if (SPEC_LONG (val->etype))
-       {
+      SPEC_CVAL (val->etype).v_float = fval;
+  else {
+      unsigned long l = fval;
+      if (SPEC_LONG (val->etype)) {
          if (SPEC_USIGN (val->etype))
-           SPEC_CVAL (val->etype).v_ulong = (unsigned long) fval;
+             SPEC_CVAL (val->etype).v_ulong = (unsigned long) l;
          else
-           SPEC_CVAL (val->etype).v_long = (long) fval;
-       }
-      else
-       {
+             SPEC_CVAL (val->etype).v_long = (long) l;
+      } else {
          if (SPEC_USIGN (val->etype))
-           SPEC_CVAL (val->etype).v_uint = (unsigned short)fval;
+             SPEC_CVAL (val->etype).v_uint = (unsigned short)l;
          else
-           SPEC_CVAL (val->etype).v_int = (short)fval;
+             SPEC_CVAL (val->etype).v_int = (short)l;
          if (SPEC_NOUN (val->etype)==V_CHAR) {
-           SPEC_CVAL (val->etype).v_uint &= 0xff; 
+             SPEC_CVAL (val->etype).v_uint &= 0xff; 
          }
-       }
-    }
+      }
+  }
   return val;
 }