fixed valCastLiteral()
authorjohanknol <johanknol@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sat, 6 Oct 2001 09:48:26 +0000 (09:48 +0000)
committerjohanknol <johanknol@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sat, 6 Oct 2001 09:48:26 +0000 (09:48 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@1359 4a8a32a2-be11-0410-ad9d-d568d2c75423

src/SDCCval.c

index 3eeb7d2bff9fa542fe665b030b1782e5f4840a6b..c540a4fe1ec2c40637d449b08293ff80c326bcc6 100644 (file)
@@ -1433,9 +1433,17 @@ valCastLiteral (sym_link * dtype, double fval)
       else
        {
          if (SPEC_USIGN (val->etype))
-           SPEC_CVAL (val->etype).v_uint = (unsigned int) fval;
+           if (SPEC_NOUN (val->etype)==V_CHAR) {
+             SPEC_CVAL (val->etype).v_uint = (unsigned char) fval;
+           } else {
+             SPEC_CVAL (val->etype).v_uint = (unsigned int) fval;
+           }
          else
-           SPEC_CVAL (val->etype).v_int = (int) fval;
+           if (SPEC_NOUN (val->etype)==V_CHAR) {
+             SPEC_CVAL (val->etype).v_int = (char) fval;
+           } else {
+             SPEC_CVAL (val->etype).v_int = (int) fval;
+           }
        }
     }
   return val;