From 8a613badb96477cc4002f624a2ead683bdd4d033 Mon Sep 17 00:00:00 2001 From: johanknol Date: Thu, 20 Sep 2001 12:53:54 +0000 Subject: [PATCH] fixed the recent bug that disabled the local structure initialisation. git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@1293 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- src/SDCCast.c | 3 ++- src/SDCCglue.c | 8 +++++++- src/SDCCsymt.c | 10 +++++----- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/SDCCast.c b/src/SDCCast.c index 4d5c02a3..89b365c4 100644 --- a/src/SDCCast.c +++ b/src/SDCCast.c @@ -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 */ diff --git a/src/SDCCglue.c b/src/SDCCglue.c index c86f5843..4352a468 100644 --- a/src/SDCCglue.c +++ b/src/SDCCglue.c @@ -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; } diff --git a/src/SDCCsymt.c b/src/SDCCsymt.c index f9bc69a0..97634105 100644 --- a/src/SDCCsymt.c +++ b/src/SDCCsymt.c @@ -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; } -- 2.39.5