Commit 4c90d796 authored by Artem Golubikhin's avatar Artem Golubikhin
Browse files

Merge branch 'PRoSToC0der-fix-public-stock-var-always-used' into 'master'

Fixed public stock variables always used

See merge request !3
parents ad9a6d67 9ed12a72
......@@ -97,6 +97,7 @@ typedef struct s_arginfo { /* function argument info */
} array;
} defvalue; /* default value, or pointer to default array */
int defvalue_tag; /* tag of the default value */
struct s_symbol *defvalue_symbol; /* symbol of the default value, if refence or array */
} arginfo;
/* Equate table, tagname table, library table */
......
......@@ -1977,7 +1977,7 @@ static void declglb(char *firstname,int firsttag,int fpublic,int fstatic,int fst
sym->usage|=uDEFINE;
} /* if */
if (ispublic)
sym->usage|=uPUBLIC|uREAD;
sym->usage|=uPUBLIC;
if (fconst)
sym->usage|=uCONST;
if (fstock)
......@@ -3660,6 +3660,7 @@ static int declargs(symbol *sym)
sym->dim.arglist[argcnt].hasdefault=FALSE;
sym->dim.arglist[argcnt].defvalue.val=0;
sym->dim.arglist[argcnt].defvalue_tag=0;
sym->dim.arglist[argcnt].defvalue_symbol=NULL;
sym->dim.arglist[argcnt].numtags=numtags;
sym->dim.arglist[argcnt].tags=(int*)malloc(numtags*sizeof tags[0]);
if (sym->dim.arglist[argcnt].tags==NULL)
......@@ -3741,6 +3742,7 @@ static void doarg(char *name,int ident,int offset,int tags[],int numtags,
arg->hasdefault=FALSE; /* preset (most common case) */
arg->defvalue.val=0; /* clear */
arg->defvalue_tag=0;
arg->defvalue_symbol=NULL;
arg->numdim=0;
if (matchtoken('[')) {
if (ident==iREFERENCE)
......@@ -3776,6 +3778,7 @@ static void doarg(char *name,int ident,int offset,int tags[],int numtags,
arg->defvalue.array.data=NULL;
arg->defvalue.array.addr=sym->addr;
arg->defvalue_tag=sym->tag;
arg->defvalue_symbol=sym;
if (sc_status==statWRITE && (sym->usage & uREAD)==0) {
markusage(sym, uREAD);
}
......@@ -4326,7 +4329,7 @@ static void reduce_referrers(symbol *root)
} /* if */
} /* for */
} else if ((sym->ident==iVARIABLE || sym->ident==iARRAY)
&& (sym->usage & uPUBLIC)==0
&& !((sym->usage & uPUBLIC)!=0 && (sym->usage & uSTOCK)==0)
&& sym->parent==NULL
&& count_referrers(sym)==0)
{
......
......@@ -2226,6 +2226,11 @@ static int nesting=0;
pushreg(sPRI); /* store the function argument on the stack */
markexpr(sPARM,NULL,0); /* mark the end of a sub-expression */
nest_stkusage++;
if (arg[argidx].defvalue_symbol!=NULL) {
if (sc_status!=statSKIP) {
markusage(arg[argidx].defvalue_symbol,uREAD); /* do not mark as "used" when this call itself is skipped */
}
}
} else {
error(88,argidx); /* argument count mismatch */
} /* if */
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment