* src/SDCCval.c (constVal): fixed bug 1305065
authorbernhardheld <bernhardheld@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Wed, 26 Oct 2005 08:27:29 +0000 (08:27 +0000)
committerbernhardheld <bernhardheld@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Wed, 26 Oct 2005 08:27:29 +0000 (08:27 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@3911 4a8a32a2-be11-0410-ad9d-d568d2c75423

ChangeLog
src/SDCCval.c

index 608a80f4398e03f2831f3d8941817534dc187041..1d77aa81fe129849731d8b566402cadff497e61a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,6 +4,7 @@
        carry must be complemented too
        * src/mcs51/peeph.def: addded rule 262 to remove double cpl c, which
        could be emitted by genMinus
+       * src/SDCCval.c (constVal): fixed bug 1305065
 
 2005-10-25 Bernhard Held <bernhard AT bernhardheld.de>
 
index 0cb48884ee96fd2ddb0f545ee87bf95ff20e4ccc..6a0095016df7888cb417d2f73b62ae103b09f24d 100644 (file)
@@ -522,47 +522,47 @@ value *constVal (char *s)
   }
 
   /* Setup the flags first */
-  /* set the b_long flag if 'lL' is found */
-  if (strchr (s, 'l') || strchr (s, 'L')) {
-    SPEC_NOUN (val->type) = V_INT;
-    SPEC_LONG (val->type) = 1;
-  }
-
   /* set the unsigned flag if 'uU' is found */
   if (strchr (s, 'u') || strchr (s, 'U')) {
     SPEC_USIGN (val->type) = 1;
   }
 
-  if (dval<0) { // "-28u" will still be signed and negative
-    if (dval<-128) { // check if we have to promote to int
-      SPEC_NOUN (val->type) = V_INT;
-    }
-    if (dval<-32768) { // check if we have to promote to long int
-      SPEC_LONG (val->type) = 1;
-    }
-  } else { // >=0
-    if (dval>0xff ||   /* check if we have to promote to int */
-        SPEC_USIGN (val->type)) { /* if it's unsigned, we can't use unsigned
-                                    char. After an integral promotion it will
-                                    be a signed int; this certainly isn't what
-                                    the programer wants */
-      SPEC_NOUN (val->type) = V_INT;
-    }
-    else { /* store char's always as unsigned; this helps other optimizations */
-      SPEC_USIGN (val->type) = 1;
-    }
-    if (dval>0xffff && SPEC_USIGN (val->type)) { // check if we have to promote to long
-      SPEC_LONG (val->type) = 1;
-    }
-    else if (dval>0x7fff && !SPEC_USIGN (val->type)) { // check if we have to promote to long int
-      if ((hex || octal) && /* hex or octal constants may be stored in unsigned type */
-          dval<=0xffff) {
+  /* set the b_long flag if 'lL' is found */
+  if (strchr (s, 'l') || strchr (s, 'L')) {
+    SPEC_NOUN (val->type) = V_INT;
+    SPEC_LONG (val->type) = 1;
+  } else {
+    if (dval<0) { // "-28u" will still be signed and negative
+      if (dval<-128) { // check if we have to promote to int
+        SPEC_NOUN (val->type) = V_INT;
+      }
+      if (dval<-32768) { // check if we have to promote to long int
+        SPEC_LONG (val->type) = 1;
+      }
+    } else { // >=0
+      if (dval>0xff || /* check if we have to promote to int */
+          SPEC_USIGN (val->type)) { /* if it's unsigned, we can't use unsigned
+                                    char. After an integral promotion it will
+                                    be a signed int; this certainly isn't what
+                                    the programer wants */
+        SPEC_NOUN (val->type) = V_INT;
+      }
+      else { /* store char's always as unsigned; this helps other optimizations */
         SPEC_USIGN (val->type) = 1;
-      } else {
+      }
+      if (dval>0xffff && SPEC_USIGN (val->type)) { // check if we have to promote to long
         SPEC_LONG (val->type) = 1;
-        if (dval>0x7fffffff) {
+      }
+      else if (dval>0x7fff && !SPEC_USIGN (val->type)) { // check if we have to promote to long int
+        if ((hex || octal) && /* hex or octal constants may be stored in unsigned type */
+            dval<=0xffff) {
           SPEC_USIGN (val->type) = 1;
-       }
+        } else {
+          SPEC_LONG (val->type) = 1;
+          if (dval>0x7fffffff) {
+            SPEC_USIGN (val->type) = 1;
+         }
+        }
       }
     }
   }