compiler/libec: Recognizing uint suffixes for expression types
authorJerome St-Louis <jerome@ecere.com>
Thu, 3 Jul 2014 08:32:58 +0000 (04:32 -0400)
committerJerome St-Louis <jerome@ecere.com>
Thu, 3 Jul 2014 08:32:58 +0000 (04:32 -0400)
compiler/bootstrap/libec/bootstrap/pass15.c
compiler/libec/src/pass15.ec

index 59a81b4..dd544dc 100644 (file)
@@ -15615,7 +15615,8 @@ unsigned int isSigned = constant[0] == '-';
 char * endP = (((void *)0));
 long long i64 = strtoll(constant, &endP, 0);
 uint64 ui64 = strtoull(constant, &endP, 0);
-unsigned int is64Bit = endP && (!strcmp(endP, "LL") || !strcmp(endP, "ll"));
+unsigned int is64Bit = endP && (!strcmp(endP, "LL") || !strcmp(endP, "ll") || !strcmp(endP, "LLU") || !strcmp(endP, "llu") || !strcmp(endP, "ull") || !strcmp(endP, "ULL"));
+unsigned int forceUnsigned = endP && (!strcmp(endP, "U") || !strcmp(endP, "u") || !strcmp(endP, "LLU") || !strcmp(endP, "llu") || !strcmp(endP, "ull") || !strcmp(endP, "ULL"));
 
 if(isSigned)
 {
@@ -15636,6 +15637,8 @@ isSigned = 1;
 else if(constant[0] != '0' || !constant[1])
 isSigned = 1;
 }
+if(forceUnsigned)
+isSigned = 0;
 type->kind = is64Bit ? 4 : 3;
 type->isSigned = isSigned;
 }
index 8a4f2a9..c8e182b 100644 (file)
@@ -8113,7 +8113,8 @@ void ProcessExpressionType(Expression exp)
                   char * endP = null;
                   int64 i64 = strtoll(constant, &endP, 0);
                   uint64 ui64 = strtoull(constant, &endP, 0);
-                  bool is64Bit = endP && (!strcmp(endP, "LL") || !strcmp(endP, "ll"));
+                  bool is64Bit = endP && (!strcmp(endP, "LL") || !strcmp(endP, "ll") || !strcmp(endP, "LLU") || !strcmp(endP, "llu") || !strcmp(endP, "ull") || !strcmp(endP, "ULL"));
+                  bool forceUnsigned = endP && (!strcmp(endP, "U") || !strcmp(endP, "u") || !strcmp(endP, "LLU") || !strcmp(endP, "llu") || !strcmp(endP, "ull") || !strcmp(endP, "ULL"));
                   if(isSigned)
                   {
                      if(i64 < MININT)
@@ -8133,6 +8134,8 @@ void ProcessExpressionType(Expression exp)
                      else if(constant[0] != '0' || !constant[1])
                         isSigned = true;
                   }
+                  if(forceUnsigned)
+                     isSigned = false;
                   type.kind = is64Bit ? int64Type : intType;
                   type.isSigned = isSigned;
                }