From: johanknol Date: Sat, 1 Dec 2001 16:11:23 +0000 (+0000) Subject: fixed bug #485513, although a warning should be thrown for non-constant initializers X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=b9c24b770f9de0b1b4bb1c3bcab113e069fc8146;p=fw%2Fsdcc fixed bug #485513, although a warning should be thrown for non-constant initializers git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@1656 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- diff --git a/src/SDCCast.c b/src/SDCCast.c index 05db77f8..f5e17f81 100644 --- a/src/SDCCast.c +++ b/src/SDCCast.c @@ -1124,11 +1124,6 @@ gatherAutoInit (symbol * autoChain) { symbol *newSym; - // this can only be a constant - if (!inInitMode && !IS_LITERAL(sym->ival->init.node->etype)) { - werror (E_CONST_EXPECTED); - } - /* insert the symbol into the symbol table */ /* with level = 0 & name = rname */ newSym = copySymbol (sym); @@ -1830,48 +1825,6 @@ reverseLoop (ast * loop, symbol * sym, ast * init, ast * end) } -//#define DEMAND_INTEGER_PROMOTION - -#ifdef DEMAND_INTEGER_PROMOTION - -/*-----------------------------------------------------------------*/ -/* walk a tree looking for the leaves. Add a typecast to the given */ -/* type to each value leaf node. */ -/*-----------------------------------------------------------------*/ -void -pushTypeCastToLeaves (sym_link * type, ast * node, ast ** parentPtr) -{ - if (!node || IS_CALLOP(node)) - { - /* WTF? We should never get here. */ - return; - } - - if (!node->left && !node->right) - { - /* We're at a leaf; if it's a value, apply the typecast */ - if (node->type == EX_VALUE && IS_INTEGRAL (TTYPE (node))) - { - *parentPtr = decorateType (newNode (CAST, - newAst_LINK (copyLinkChain (type)), - node)); - } - } - else - { - if (node->left) - { - pushTypeCastToLeaves (type, node->left, &(node->left)); - } - if (node->right) - { - pushTypeCastToLeaves (type, node->right, &(node->right)); - } - } -} - -#endif - /*-----------------------------------------------------------------*/ /* decorateType - compute type for this tree also does type cheking */ /* this is done bottom up, since type have to flow upwards */ @@ -4294,10 +4247,6 @@ createFunction (symbol * name, ast * body) name->lastLine = yylineno; currFunc = name; -#if 0 // jwk: this is now done in addDecl() - processFuncArgs (currFunc); -#endif - /* set the stack pointer */ /* PENDING: check this for the mcs51 */ stackPtr = -port->stack.direction * port->stack.call_overhead; diff --git a/src/ds390/gen.c b/src/ds390/gen.c index d01c1d7e..9db62c56 100644 --- a/src/ds390/gen.c +++ b/src/ds390/gen.c @@ -2269,7 +2269,7 @@ genCall (iCode * ic) the same register bank then we need to save the destination registers on the stack */ dtype = operandType (IC_LEFT (ic)); - if (dtype && !IFFUNC_ISNAKED(dtype) && + if (currFunc && dtype && !IFFUNC_ISNAKED(dtype) && (FUNC_REGBANK (currFunc->type) != FUNC_REGBANK (dtype)) && IFFUNC_ISISR (currFunc->type)) { @@ -2479,7 +2479,7 @@ genPcall (iCode * ic) the same register bank then we need to save the destination registers on the stack */ dtype = operandType (IC_LEFT (ic)); - if (dtype && !IFFUNC_ISNAKED(dtype) && + if (currFunc && dtype && !IFFUNC_ISNAKED(dtype) && IFFUNC_ISISR (currFunc->type) && (FUNC_REGBANK (currFunc->type) != FUNC_REGBANK (dtype))) { saveRBank (FUNC_REGBANK (dtype), ic, TRUE); diff --git a/src/mcs51/gen.c b/src/mcs51/gen.c index 6ea17c48..7a2c5f30 100644 --- a/src/mcs51/gen.c +++ b/src/mcs51/gen.c @@ -1925,7 +1925,7 @@ genCall (iCode * ic) the same register bank then we need to save the destination registers on the stack */ dtype = operandType (IC_LEFT (ic)); - if (dtype && !IFFUNC_ISNAKED(dtype) && + if (currFunc && dtype && !IFFUNC_ISNAKED(dtype) && (FUNC_REGBANK (currFunc->type) != FUNC_REGBANK (dtype)) && IFFUNC_ISISR (currFunc->type)) { @@ -2023,7 +2023,7 @@ genPcall (iCode * ic) the same register bank then we need to save the destination registers on the stack */ dtype = operandType (IC_LEFT (ic)); - if (dtype && !FUNC_ISNAKED(dtype) && + if (currFunc && dtype && !FUNC_ISNAKED(dtype) && IFFUNC_ISISR (currFunc->type) && (FUNC_REGBANK (currFunc->type) != FUNC_REGBANK (dtype))) { saveRBank (FUNC_REGBANK (dtype), ic, TRUE); @@ -2568,7 +2568,6 @@ genEndFunction (iCode * ic) emitcode ("setb", "ea"); /* if debug then send end of function */ - /* if (options.debug && currFunc) */ if (options.debug && currFunc) { _G.debugLine = 1; @@ -8788,7 +8787,6 @@ gen51Code (iCode * lic) if (allocInfo) printAllocInfo (currFunc, codeOutFile); /* if debug information required */ - /* if (options.debug && currFunc) { */ if (options.debug && currFunc) { cdbSymbol (currFunc, cdbFile, FALSE, TRUE); diff --git a/src/pic/gen.c b/src/pic/gen.c index 19197447..50f5c867 100644 --- a/src/pic/gen.c +++ b/src/pic/gen.c @@ -1898,7 +1898,7 @@ static void saveRegisters(iCode *lic) } dtype = operandType(IC_LEFT(ic)); - if (dtype && + if (currFunc && dtype && (FUNC_REGBANK(currFunc->type) != FUNC_REGBANK(dtype)) && IFFUNC_ISISR(currFunc->type) && !ic->bankSaved) @@ -2189,7 +2189,7 @@ static void genCall (iCode *ic) the same register bank then we need to save the destination registers on the stack */ dtype = operandType(IC_LEFT(ic)); - if (dtype && + if (currFunc && dtype && (FUNC_REGBANK(currFunc->type) != FUNC_REGBANK(dtype)) && IFFUNC_ISISR(currFunc->type) && !ic->bankSaved) @@ -2322,7 +2322,7 @@ static void genPcall (iCode *ic) the same register bank then we need to save the destination registers on the stack */ dtype = operandType(IC_LEFT(ic)); - if (dtype && + if (currFunc && dtype && IFFUNC_ISISR(currFunc->type) && (FUNC_REGBANK(currFunc->type) != FUNC_REGBANK(dtype))) saverbank(FUNC_REGBANK(dtype),ic,TRUE); @@ -2404,7 +2404,7 @@ static void genPcall (iCode *ic) } /* if register bank was saved then unsave them */ - if (dtype && + if (currFunc && dtype && (FUNC_REGBANK(currFunc->type) != FUNC_REGBANK(dtype))) unsaverbank(FUNC_REGBANK(dtype),ic,TRUE); diff --git a/support/Util/SDCCerr.c b/support/Util/SDCCerr.c index ed6eebd6..f40432d9 100644 --- a/support/Util/SDCCerr.c +++ b/support/Util/SDCCerr.c @@ -54,7 +54,7 @@ struct { E_SYNTAX_ERROR, ERROR_LEVEL_ERROR, "Syntax error, declaration ignored at '%s'" }, { E_CONST_EXPECTED, ERROR_LEVEL_ERROR, - "Constant Expected Found Variable" }, + "Initializer element is not constant" }, { E_OUT_OF_MEM, ERROR_LEVEL_ERROR, "'malloc' failed file '%s' for size %ld" }, { E_FILE_OPEN_ERR, ERROR_LEVEL_ERROR,