From: johanknol Date: Mon, 24 Dec 2001 16:57:38 +0000 (+0000) Subject: some small fixes X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=6cf005ad44bcebf9a5d6f6b8efdac2f85488cfa8;p=fw%2Fsdcc some small fixes git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@1737 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- diff --git a/src/SDCCast.c b/src/SDCCast.c index c121d7c2..15f59285 100644 --- a/src/SDCCast.c +++ b/src/SDCCast.c @@ -1170,6 +1170,12 @@ bool constExprTree (ast *cexpr) { // a function's address will never change return TRUE; } + if (IS_AST_SYM_VALUE(cexpr) && + IN_CODESPACE(SPEC_OCLS(AST_SYMBOL(cexpr)->etype))) { + // a symbol in code space will never change + // This is only for the 'char *s="hallo"' case and will have to leave + return TRUE; + } return FALSE; case EX_LINK: werror (E_INTERNAL_ERROR, __FILE__, __LINE__, @@ -1177,6 +1183,7 @@ bool constExprTree (ast *cexpr) { return FALSE; case EX_OP: if (cexpr->opval.op==ARRAYINIT) { + fprintf (stderr, "skipping arrayinit\n"); // this is a list of literals return TRUE; } diff --git a/src/SDCCglue.c b/src/SDCCglue.c index 6f89cb01..e1e8f323 100644 --- a/src/SDCCglue.c +++ b/src/SDCCglue.c @@ -272,14 +272,14 @@ emitRegularMap (memmap * map, bool addPublics, bool arFlag) if (ival) { // set ival's lineno to where the symbol was defined setAstLineno (ival, lineno=sym->lineDef); - // check if this is a constant expression - if (constExprTree(ival)) { - allocInfo = 0; - eBBlockFromiCode (iCodeFromAst (ival)); - allocInfo = 1; - } else { + // check if this is not a constant expression + if (!constExprTree(ival)) { werror (E_CONST_EXPECTED, "found expression"); + // but try to do it anyway } + allocInfo = 0; + eBBlockFromiCode (iCodeFromAst (ival)); + allocInfo = 1; } #endif } diff --git a/src/SDCCmem.c b/src/SDCCmem.c index a0e137d4..f369a04f 100644 --- a/src/SDCCmem.c +++ b/src/SDCCmem.c @@ -381,16 +381,19 @@ allocGlobal (symbol * sym) } /* if it is fixed, then allocate depending on the */ - /* current memory model,same for automatics */ + /* current memory model, same for automatics */ if (SPEC_SCLS (sym->etype) == S_FIXED || - SPEC_SCLS (sym->etype) == S_AUTO) - { + SPEC_SCLS (sym->etype) == S_AUTO) { + if (port->mem.default_globl_map != xdata) { /* set the output class */ SPEC_OCLS (sym->etype) = port->mem.default_globl_map; /* generate the symbol */ allocIntoSeg (sym); return; + } else { + SPEC_SCLS (sym->etype) = S_XDATA; } + } /* if code change to constant */ if (SPEC_SCLS (sym->etype) == S_CODE) {