fixed the recent bug that disabled the local structure initialisation.
authorjohanknol <johanknol@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Thu, 20 Sep 2001 12:53:54 +0000 (12:53 +0000)
committerjohanknol <johanknol@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Thu, 20 Sep 2001 12:53:54 +0000 (12:53 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@1293 4a8a32a2-be11-0410-ad9d-d568d2c75423

src/SDCCast.c
src/SDCCglue.c
src/SDCCsymt.c

index 4d5c02a3ae3f5fe75f2caed974e3679db91094ca..89b365c48ffe9104ca8aa360620cdf9ea4129c2c 100644 (file)
@@ -1221,6 +1221,7 @@ processBlockVars (ast * tree, int *stack, int action)
 
 /*-----------------------------------------------------------------*/
 /* constExprValue - returns the value of a constant expression     */
+/*                  or NULL if it is not a constant expression     */
 /*-----------------------------------------------------------------*/
 value *
 constExprValue (ast * cexpr, int check)
@@ -1258,7 +1259,7 @@ constExprValue (ast * cexpr, int check)
       if (check)
        werror (E_CONST_EXPECTED, "found expression");
 
-      return constVal("0");
+      return NULL;
     }
 
   /* return the value */
index c86f5843a2bda19f2dbadfc11610508c6b15888d..4352a468388b973e5111c9ad8e4cf95bb9682641 100644 (file)
@@ -99,6 +99,11 @@ aopLiteralLong (value * val, int offset, int size)
        }
        fl;
 
+       if (!val) {
+         // assuming we have been warned before
+         val=constVal("0");
+       }
+
        /* if it is a float then it gets tricky */
        /* otherwise it is fairly simple */
        if (!IS_FLOAT (val->type)) {
@@ -268,6 +273,7 @@ emitRegularMap (memmap * map, bool addPublics, bool arFlag)
            segment = SPEC_OCLS (symIval->etype);
            deleteSetItem (&segment->syms, symIval);
          }
+
          sym->ival = NULL;
        }
     }
@@ -377,7 +383,7 @@ initPointer (initList * ilist)
        }
  wrong:
        werror (W_INIT_WRONG);
-       return constVal("0");
+       return NULL;
 
 }
 
index f9bc69a0f94bdd95193ac72ab8248acc3606b745..97634105617769ecf20aeada191e8234d3126715 100644 (file)
@@ -1242,7 +1242,7 @@ checkSClass (symbol * sym, int isProto)
     /* initializers if not an extern */
     if (SPEC_SCLS (sym->etype) == S_CODE &&
        sym->ival == NULL &&
-       !sym->level &&
+       //!sym->level &&
        port->mem.code_ro &&
        !IS_EXTERN (sym->etype) &&
        !funcInChain (sym->type))
@@ -1428,9 +1428,9 @@ computeType (sym_link * type1, sym_link * type2)
   return rType;
 }
 
-/*------------------------------------------------------------------*/
-/* compareType - will do type check return 1 if match                 */
-/*------------------------------------------------------------------*/
+/*--------------------------------------------------------------------*/
+/* compareType - will do type check return 1 if match, -1 if castable */
+/*--------------------------------------------------------------------*/
 int 
 compareType (sym_link * dest, sym_link * src)
 {
@@ -1508,7 +1508,7 @@ compareType (sym_link * dest, sym_link * src)
     return -1;
 
   if (SPEC_USIGN (dest) != SPEC_USIGN (src))
-    return -2;
+    return -1;
 
   return 1;
 }