Too much opposition against these range checks. It will only work now with --pedantic...
authorjohanknol <johanknol@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Mon, 1 Oct 2001 14:21:56 +0000 (14:21 +0000)
committerjohanknol <johanknol@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Mon, 1 Oct 2001 14:21:56 +0000 (14:21 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@1337 4a8a32a2-be11-0410-ad9d-d568d2c75423

src/SDCCicode.c
src/SDCCicode.h
src/SDCCval.c

index 30bd5985e4fe14c329f779484eac17295f81ab0f..6d1b6b8941b1ef3df76ca1a2fdbef432692d5a94 100644 (file)
@@ -131,11 +131,12 @@ iCodeTable codeTable[] =
      pedantic>1: "char c=200" is not allowed (evaluates to -56)
 */
 
-void checkConstantRange(sym_link *ltype, double v, char *msg, int pedantic) {
+void checkConstantRange(sym_link *ltype, value *val, char *msg, int pedantic) {
   LONG_LONG max = (LONG_LONG) 1 << bitsForType(ltype);
   char message[132]="";
   int warnings=0;
   int negative=0;
+  long v=SPEC_CVAL(val->type).v_long;
 
 #if 0
   // this could be a good idea
@@ -148,10 +149,9 @@ void checkConstantRange(sym_link *ltype, double v, char *msg, int pedantic) {
     return;
   }
 
-  if (v<0) {
+  if (!SPEC_USIGN(val->type) && v<0) {
     negative=1;
-    // if not pedantic: -1 equals to 0xf..f
-    if (SPEC_USIGN(ltype) && (!pedantic ? v!=-1 : 1)) {
+    if (SPEC_USIGN(ltype) && (pedantic>1)) {
       warnings++;
     }
     v=-v;
@@ -2507,7 +2507,7 @@ geniCodeLogic (operand * left, operand * right, int op)
   if (IS_INTEGRAL (ltype) && IS_VALOP (right) && IS_LITERAL (rtype))
     {
       checkConstantRange(ltype, 
-                        operandLitValue(right), "compare operation", 1);
+                        OP_VALUE(right), "compare operation", 1);
     }
 
   ctype = usualBinaryConversions (&left, &right);
@@ -2600,7 +2600,7 @@ geniCodeAssign (operand * left, operand * right, int nosupdate)
   if (IS_INTEGRAL (ltype) && right->type == VALUE && IS_LITERAL (rtype))
     {
       checkConstantRange(ltype, 
-                        operandLitValue(right), "= operation", 0);
+                        OP_VALUE(right), "= operation", 0);
     }
 
   /* if the left & right type don't exactly match */
index 5b6f38754342559ab31f1175cf5267d1a258a18d..4156e257fde85a3adda835b4d907d6f981c084e5 100644 (file)
@@ -68,6 +68,7 @@ OPTYPE;
 #define OP_SYMBOL(op)      op->operand.symOperand
 #define OP_SYM_TYPE(op)    op->operand.symOperand->type
 #define OP_SYM_ETYPE(op)   op->operand.symOperand->etype
+#define OP_VALUE(op)       op->operand.valOperand
 #define SPIL_LOC(op)       op->operand.symOperand->usl.spillLoc
 #define OP_LIVEFROM(op)    op->operand.symOperand->liveFrom
 #define OP_LIVETO(op)      op->operand.symOperand->liveTo
index 7c16fbdbbb5975c46fcfcd716e3fae275ba4c331..845faf3ff32eca486d793e365211286b42952f4f 100644 (file)
@@ -373,8 +373,10 @@ constVal (char *s)
   SPEC_NOUN (val->type) = V_INT;
   SPEC_SCLS (val->type) = S_LITERAL;
 
-  /* set the _unsigned flag if 'uU' found */
-  if (strchr (s, 'u') || strchr (s, 'U'))
+  /* set the _unsigned flag if 'uUoOxX' found */
+  if (strchr (s, 'u') || strchr (s, 'U') ||
+      strchr (s, 'o') || strchr (s, 'O') ||
+      strchr (s, 'x') || strchr (s, 'x'))
     SPEC_USIGN (val->type) = 1;
 
   /* set the _long flag if 'lL' is found */
@@ -711,6 +713,7 @@ charVal (char *s)
   val->type = val->etype = newLink ();
   val->type->class = SPECIFIER;
   SPEC_NOUN (val->type) = V_CHAR;
+  SPEC_USIGN(val->type) = 1;
   SPEC_SCLS (val->type) = S_LITERAL;
 
   s++;                         /* get rid of quotation */