From: johanknol Date: Thu, 28 Jun 2001 11:24:12 +0000 (+0000) Subject: storage class specifiers are allowed for static autos in reentrant functions X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=6812b951155467655aaaccb587131b8a403d2988;p=fw%2Fsdcc storage class specifiers are allowed for static autos in reentrant functions git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@978 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- diff --git a/src/SDCCmain.c b/src/SDCCmain.c index 0f7b4875..31d5fdca 100644 --- a/src/SDCCmain.c +++ b/src/SDCCmain.c @@ -370,13 +370,13 @@ printUsage () { int i; printVersionInfo(); - fprintf (stderr, + fprintf (stdout, "Usage : sdcc [options] filename\n" "Options :-\n" ); for (i = 0; i < LENGTH(optionsTable); i++) { - fprintf(stderr, " %c%c %-20s %s\n", + fprintf(stdout, " %c%c %-20s %s\n", optionsTable[i].shortOpt !=0 ? '-' : ' ', optionsTable[i].shortOpt !=0 ? optionsTable[i].shortOpt : ' ', optionsTable[i].longOpt != NULL ? optionsTable[i].longOpt : "", diff --git a/src/SDCCmem.c b/src/SDCCmem.c index a84bceff..5a447ccc 100644 --- a/src/SDCCmem.c +++ b/src/SDCCmem.c @@ -582,35 +582,27 @@ allocLocal (symbol * sym) /* this is automatic */ /* if it to be placed on the stack */ - if (options.stackAuto || reentrant) - { - - sym->onStack = 1; - if (options.useXstack) - { - /* PENDING: stack direction for xstack */ - SPEC_OCLS (sym->etype) = xstack; - SPEC_STAK (sym->etype) = sym->stack = (xstackPtr + 1); - xstackPtr += getSize (sym->type); - } - else - { - SPEC_OCLS (sym->etype) = istack; - if (port->stack.direction > 0) - { - SPEC_STAK (sym->etype) = sym->stack = (stackPtr + 1); - stackPtr += getSize (sym->type); - } - else - { - stackPtr -= getSize (sym->type); - SPEC_STAK (sym->etype) = sym->stack = stackPtr; - } - } - allocIntoSeg (sym); - return; + if (options.stackAuto || reentrant) { + sym->onStack = 1; + if (options.useXstack) { + /* PENDING: stack direction for xstack */ + SPEC_OCLS (sym->etype) = xstack; + SPEC_STAK (sym->etype) = sym->stack = (xstackPtr + 1); + xstackPtr += getSize (sym->type); + } else { + SPEC_OCLS (sym->etype) = istack; + if (port->stack.direction > 0) { + SPEC_STAK (sym->etype) = sym->stack = (stackPtr + 1); + stackPtr += getSize (sym->type); + } else { + stackPtr -= getSize (sym->type); + SPEC_STAK (sym->etype) = sym->stack = stackPtr; + } } - + allocIntoSeg (sym); + return; + } + /* else depending on the storage class specified */ if (SPEC_SCLS (sym->etype) == S_XDATA) { diff --git a/src/SDCCsymt.c b/src/SDCCsymt.c index ee4bfe42..98fd50fe 100644 --- a/src/SDCCsymt.c +++ b/src/SDCCsymt.c @@ -1178,6 +1178,7 @@ checkSClass (symbol * sym) sym->ival = NULL; } +#if 0 /* if this is an automatic symbol then */ /* storage class will be ignored and */ /* symbol will be allocated on stack/ */ @@ -1193,6 +1194,23 @@ checkSClass (symbol * sym) werror (E_AUTO_ASSUMED, sym->name); SPEC_SCLS (sym->etype) = S_AUTO; } +#else + /* if this is an atomatic symbol */ + if (sym->level && (options.stackAuto || reentrant)) { + if ((SPEC_SCLS (sym->etype) == S_AUTO || + SPEC_SCLS (sym->etype) == S_FIXED || + SPEC_SCLS (sym->etype) == S_REGISTER || + SPEC_SCLS (sym->etype) == S_STACK || + SPEC_SCLS (sym->etype) == S_XSTACK)) { + SPEC_SCLS (sym->etype) = S_AUTO; + } else { + /* storage class may only be specified for statics */ + if (!IS_STATIC(sym->etype)) { + werror (E_AUTO_ASSUMED, sym->name); + } + } + } +#endif /* automatic symbols cannot be given */ /* an absolute address ignore it */ diff --git a/support/Util/SDCCerr.c b/support/Util/SDCCerr.c index 0933c145..617e7c3f 100644 --- a/support/Util/SDCCerr.c +++ b/support/Util/SDCCerr.c @@ -83,8 +83,8 @@ struct " a 'sfr','sbit' storage class, initial value ignored '%s'" }, { E_INIT_IGNORED, ERROR_LEVEL_WARNING, "Variable in the storage class cannot be initialized.'%s'" }, -{ E_AUTO_ASSUMED, ERROR_LEVEL_WARNING, - "storage class not allowed for automatic variable '%s' in reentrant function" }, +{ E_AUTO_ASSUMED, ERROR_LEVEL_ERROR, + "storage class not allowed for automatic variable '%s' in reentrant function unless static" }, { E_AUTO_ABSA, ERROR_LEVEL_ERROR, "absolute address not allowed for automatic var '%s' in reentrant function " }, { E_INIT_WRONG, ERROR_LEVEL_WARNING,