corrected improper use of assert
[fw/sdcc] / src / SDCCval.c
index 59cb58726ea60b3de136a709c625dc62848d7fef..72c73a1888cc1d7e21dc2dfc1ed413326f2686c6 100644 (file)
@@ -907,6 +907,10 @@ floatFromVal (value * val)
     return (double) SPEC_CVAL (val->etype).v_ulong;
   }
 
+  if (SPEC_NOUN (val->etype) == V_VOID) {
+    return (double) SPEC_CVAL (val->etype).v_ulong;
+  }
+
   // we are lost !
   werror (E_INTERNAL_ERROR, __FILE__, __LINE__,
          "floatFromVal: unknown value");
@@ -942,6 +946,12 @@ valUnaryPM (value * val)
     }
   // -(unsigned 3) now really is signed
   SPEC_USIGN(val->etype)=0;
+  // -(unsigned char)135 now really is an int
+  if (SPEC_NOUN(val->etype) == V_CHAR) {
+    if (SPEC_CVAL(val->etype).v_int < -128) {
+      SPEC_NOUN(val->etype) = V_INT;
+    }
+  }
   return val;
 }
 
@@ -966,6 +976,8 @@ valComplement (value * val)
       else
        SPEC_CVAL (val->etype).v_int = ~SPEC_CVAL (val->etype).v_int;
     }
+  // ~(unsigned 3) now really is signed
+  SPEC_USIGN(val->etype)=0;
   return val;
 }
 
@@ -1451,7 +1463,7 @@ getNelements (sym_link * type, initList * ilist)
   if (!ilist)
     return 0;
 
-  if (ilist->type == INIT_DEEP)
+  while (ilist->type == INIT_DEEP)
     ilist = ilist->init.deep;
 
   /* if type is a character array and there is only one
@@ -1462,7 +1474,7 @@ getNelements (sym_link * type, initList * ilist)
       value *v = (iast->type == EX_VALUE ? iast->opval.val : NULL);
       if (!v)
        {
-         werror (W_INIT_WRONG);
+         werror (E_CONST_EXPECTED);
          return 0;
        }