Force a reparse if function is used before declared

Fixes #131.
This commit is contained in:
Zeex 2017-01-22 01:16:54 +06:00
parent ecfb7cf69e
commit 5bedccc36d

View File

@ -3324,19 +3324,21 @@ SC_FUNC char *funcdisplayname(char *dest,char *funcname)
static void check_reparse(symbol *sym)
{
/* 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 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 ((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);
sc_status=curstatus;
sc_reparse=TRUE; /* must add another pass to "initial scan" phase */
} /* if */
if ((sym->usage & (uPROTOTYPED | uREAD))==uREAD)
sc_reparse=TRUE; /* must add another pass to "initial scan" phase */
}
static void funcstub(int fnative)
@ -3739,7 +3741,7 @@ static int declargs(symbol *sym,int chkshadow)
ident=iVARIABLE;
numtags=0;
fconst=FALSE;
fpublic= (sym->usage & uPUBLIC)!=0;
fpublic=(sym->usage & uPUBLIC)!=0;
/* the '(' parantheses has already been parsed */
if (!matchtoken(')')){
do { /* there are arguments; process them */