Mark symbols as read when they are passed as function arguments
This is an improved version of the earlier fix for bug #131. Also should fix https://github.com/Misiur/YSI-Includes/issues/154.
This commit is contained in:
parent
95f19b7284
commit
f9e9c181dd
@ -189,7 +189,6 @@ typedef struct s_symbol {
|
||||
* 6 (uSTOCK) the function is discardable (without warning)
|
||||
* 7 (uMISSING) the function is not implemented in this source file
|
||||
* 8 (uFORWARD) the function is explicitly forwardly declared
|
||||
* 9 (uGLOBALARGS) the function is called with global variables as arguments
|
||||
*
|
||||
* CONSTANT
|
||||
* bits: 0 (uDEFINE) the symbol is defined in the source file
|
||||
@ -213,7 +212,6 @@ typedef struct s_symbol {
|
||||
#define uENUMFIELD 0x040
|
||||
#define uMISSING 0x080
|
||||
#define uFORWARD 0x100
|
||||
#define uGLOBALARGS 0x200
|
||||
/* uRETNONE is not stored in the "usage" field of a symbol. It is
|
||||
* used during parsing a function, to detect a mix of "return;" and
|
||||
* "return value;" in a few special cases.
|
||||
|
@ -3325,21 +3325,13 @@ SC_FUNC char *funcdisplayname(char *dest,char *funcname)
|
||||
|
||||
static void check_reparse(symbol *sym)
|
||||
{
|
||||
/* if the function was used before being declared, add a third pass (as
|
||||
* second "skimming" parse) because:
|
||||
*
|
||||
* - the function result may have been used with user-defined operators,
|
||||
* which have now been incorrectly flagged (as the return tag was unknown
|
||||
* at the time of the call)
|
||||
*
|
||||
* - one or more of the function's arguments involve global variables that
|
||||
* have been declared before the function; in this situation the arguments
|
||||
* are uknown at the time the funtion is called, so the variable may not
|
||||
* be marked as read (uREAD) and may therefore be omitted from the
|
||||
* resulting P-code
|
||||
/* if the function was used before being declared, and it has a tag for the
|
||||
* result, add a third pass (as second "skimming" parse) because the function
|
||||
* result may have been used with user-defined operators, which have now
|
||||
* been incorrectly flagged (as the return tag was unknown at the time of
|
||||
* the call)
|
||||
*/
|
||||
if ((sym->usage & (uPROTOTYPED | uREAD))==uREAD
|
||||
&& (sym->tag!=0 || (sym->usage & uGLOBALARGS)!=0)) {
|
||||
if ((sym->usage & (uPROTOTYPED | uREAD))==uREAD && sym->tag!=0) {
|
||||
int curstatus=sc_status;
|
||||
sc_status=statWRITE; /* temporarily set status to WRITE, so the warning isn't blocked */
|
||||
error(208);
|
||||
|
@ -2077,9 +2077,14 @@ static int nesting=0;
|
||||
if (arg[argidx].ident!=0 && arg[argidx].numtags==1)
|
||||
lval.cmptag=arg[argidx].tags[0]; /* set the expected tag, if any */
|
||||
lvalue=hier14(&lval);
|
||||
/* Mark the symbol as "read" so it won't be omitted from P-code.
|
||||
* Native functions are marked as read at the point of their call,
|
||||
* so we don't handle them here; see ffcall().
|
||||
*/
|
||||
if (lval.sym!=NULL && (lval.sym->usage & uNATIVE)==0) {
|
||||
markusage(lval.sym,uREAD);
|
||||
} /* if */
|
||||
assert(sc_status==statFIRST || arg[argidx].ident==0 || arg[argidx].tags!=NULL);
|
||||
if (lval.sym!=NULL && lval.sym->ident==iVARIABLE && lval.sym->vclass==sGLOBAL)
|
||||
sym->usage|=uGLOBALARGS;
|
||||
switch (arg[argidx].ident) {
|
||||
case 0:
|
||||
error(202); /* argument count mismatch */
|
||||
|
@ -161,7 +161,7 @@ static char *warnmsg[] = {
|
||||
/*205*/ "redundant code: constant expression is zero\n",
|
||||
/*206*/ "redundant test: constant expression is non-zero\n",
|
||||
/*207*/ "unknown #pragma\n",
|
||||
/*208*/ "function with tag result or global variables as arguments is used before definition, forcing reparse\n",
|
||||
/*208*/ "function with tag result used before definition, forcing reparse\n",
|
||||
/*209*/ "function \"%s\" should return a value\n",
|
||||
/*210*/ "possible use of symbol before initialization: \"%s\"\n",
|
||||
/*211*/ "possibly unintended assignment\n",
|
||||
|
Loading…
x
Reference in New Issue
Block a user