* src/SDCCval.c (constVal): Fixed usage of 'L' modifier problems on ppc.
authormichaelh <michaelh@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sat, 13 Oct 2001 17:50:10 +0000 (17:50 +0000)
committermichaelh <michaelh@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sat, 13 Oct 2001 17:50:10 +0000 (17:50 +0000)
* support/regression/tests/longor.c: Added.

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

ChangeLog
src/SDCCval.c

index c8b25d8cedeb552406cf8fe57e3840ddb2f8f132..e7abfd352b2019dc5f51d2dd8bbfb21ef7ef03e9 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2001-10-13  Michael Hope  <michaelh@juju.net.nz>
+
+       * src/SDCCval.c (constVal): Fixed usage of 'L' modifier problems on ppc.
+
+       * support/regression/tests/longor.c: Added.
+
 2001-10-11  Bernhard Held  <bernhard@bernhardheld.de>
 
        * as/mcs51/asdata.c: replaced FILENAME_MAX with PATH_MAX
index 6d645ee200cfa4010ebe33ed34364520ce58b9ff..cee4dde16f1340185d3423a6fe7dff44cd180a93 100644 (file)
@@ -436,10 +436,6 @@ value *constVal (char *s)
   SPEC_NOUN (val->type) = V_CHAR;
   SPEC_USIGN (val->type) = 1;
 
-  /* set the _long flag if 'lL' is found */
-  if (strchr (s, 'l') || strchr (s, 'L'))
-    SPEC_LONG (val->type) = 1;
-
   hex = ((strchr (s, 'x') || strchr (s, 'X')) ? 1 : 0);
 
   /* set the octal flag   */
@@ -463,14 +459,17 @@ value *constVal (char *s)
 
   sscanf (s, scanFmt, &sval);
 
+  /* Setup the flags first */
+  /* set the _long flag if 'lL' is found */
+  if (strchr (s, 'l') || strchr (s, 'L'))
+    SPEC_LONG (val->type) = 1;
+
   if (sval<0) { // "-28u" will still be signed and negative
     SPEC_USIGN (val->type) = 0;
     if (sval<-32768) { // check if we have to promote to long
       SPEC_NOUN (val->type) = V_INT;
       SPEC_LONG (val->type) = 1;
-      SPEC_CVAL (val->type).v_long=sval;
     } else {
-      SPEC_CVAL (val->type).v_int=sval;
       if (sval<-128) { // check if we have to promote to int
        SPEC_NOUN (val->type) = V_INT;
       }
@@ -479,15 +478,36 @@ value *constVal (char *s)
     if (sval>0xffff) { // check if we have to promote to long
       SPEC_NOUN (val->type) = V_INT;
       SPEC_LONG (val->type) = 1;
-      SPEC_CVAL (val->type).v_ulong=sval;
     } else {
-      SPEC_CVAL (val->type).v_uint=sval;
       if (sval>0xff) { // check if we have to promote to int
        SPEC_NOUN (val->type) = V_INT;
       }
     }
   }
 
+  if (SPEC_LONG (val->type))
+    {
+      if (SPEC_USIGN (val->type))
+        {
+          SPEC_CVAL (val->type).v_ulong = sval;
+        }
+      else
+        {
+          SPEC_CVAL (val->type).v_long = sval;
+        }
+    }
+  else
+    {
+      if (SPEC_USIGN (val->type))
+        {
+          SPEC_CVAL (val->type).v_uint = sval;
+        }
+      else
+        {
+          SPEC_CVAL (val->type).v_int = sval;
+        }
+    }
+
   return val;
 }