Squashed commit of the following:
commit b32aea5faf3cf5168cf69b1143de6b49853f0879 Author: Yashas <yashas_2010@yahoo.com> Date: Tue Oct 16 23:07:47 2018 +0530 add test for issue #371 commit 66bbe6c4df3593c28fcc229b04c2be428d1da070 Author: Yashas <yashas_2010@yahoo.com> Date: Wed Oct 3 17:05:10 2018 +0530 share usage information across function definitions
This commit is contained in:
parent
65d6c98fc2
commit
79101592e7
@ -108,7 +108,7 @@ static void funcstub(int fnative);
|
|||||||
static int newfunc(char *firstname,int firsttag,int fpublic,int fstatic,int stock);
|
static int newfunc(char *firstname,int firsttag,int fpublic,int fstatic,int stock);
|
||||||
static int declargs(symbol *sym,int chkshadow);
|
static int declargs(symbol *sym,int chkshadow);
|
||||||
static void doarg(char *name,int ident,int offset,int tags[],int numtags,
|
static void doarg(char *name,int ident,int offset,int tags[],int numtags,
|
||||||
int fpublic,int fconst,int chkshadow,arginfo *arg);
|
int fpublic,int fconst,int written,int chkshadow,arginfo *arg);
|
||||||
static void make_report(symbol *root,FILE *log,char *sourcefile);
|
static void make_report(symbol *root,FILE *log,char *sourcefile);
|
||||||
static void reduce_referrers(symbol *root);
|
static void reduce_referrers(symbol *root);
|
||||||
static long max_stacksize(symbol *root,int *recursion);
|
static long max_stacksize(symbol *root,int *recursion);
|
||||||
@ -3697,8 +3697,8 @@ static void funcstub(int fnative)
|
|||||||
*/
|
*/
|
||||||
static int newfunc(char *firstname,int firsttag,int fpublic,int fstatic,int stock)
|
static int newfunc(char *firstname,int firsttag,int fpublic,int fstatic,int stock)
|
||||||
{
|
{
|
||||||
symbol *sym;
|
symbol *sym,*lvar,*depend;
|
||||||
int argcnt,tok,tag,funcline;
|
int argcnt,tok,tag,funcline,i;
|
||||||
int opertok,opererror;
|
int opertok,opererror;
|
||||||
char symbolname[sNAMEMAX+1];
|
char symbolname[sNAMEMAX+1];
|
||||||
char *str;
|
char *str;
|
||||||
@ -3874,6 +3874,26 @@ static int newfunc(char *firstname,int firsttag,int fpublic,int fstatic,int stoc
|
|||||||
dumplits(); /* dump literal strings */
|
dumplits(); /* dump literal strings */
|
||||||
litidx=0;
|
litidx=0;
|
||||||
} /* if */
|
} /* if */
|
||||||
|
for (i=0; i<argcnt; i++) {
|
||||||
|
if (sym->dim.arglist[i].ident==iREFARRAY) {
|
||||||
|
lvar=findloc(sym->dim.arglist[i].name);
|
||||||
|
assert(lvar!=NULL);
|
||||||
|
if ((sym->dim.arglist[i].usage & uWRITTEN)==0) {
|
||||||
|
/* check if the argument was written in this definition */
|
||||||
|
depend=lvar;
|
||||||
|
while (depend!=NULL) {
|
||||||
|
if ((depend->usage & uWRITTEN)!=0) {
|
||||||
|
sym->dim.arglist[i].usage|=depend->usage & uWRITTEN;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
depend=finddepend(depend);
|
||||||
|
} /* while */
|
||||||
|
} /* if */
|
||||||
|
/* mark argument as written if it was written in another definition */
|
||||||
|
lvar->usage|=sym->dim.arglist[i].usage & uWRITTEN;
|
||||||
|
} /* if */
|
||||||
|
} /* for */
|
||||||
|
|
||||||
testsymbols(&loctab,0,TRUE,TRUE); /* test for unused arguments and labels */
|
testsymbols(&loctab,0,TRUE,TRUE); /* test for unused arguments and labels */
|
||||||
delete_symbols(&loctab,0,TRUE,TRUE); /* clear local variables queue */
|
delete_symbols(&loctab,0,TRUE,TRUE); /* clear local variables queue */
|
||||||
assert(loctab.next==NULL);
|
assert(loctab.next==NULL);
|
||||||
@ -4018,7 +4038,7 @@ static int declargs(symbol *sym,int chkshadow)
|
|||||||
* base + 3*sizeof(cell) == first argument of the function
|
* base + 3*sizeof(cell) == first argument of the function
|
||||||
* So the offset of each argument is "(argcnt+3) * sizeof(cell)".
|
* So the offset of each argument is "(argcnt+3) * sizeof(cell)".
|
||||||
*/
|
*/
|
||||||
doarg(name,ident,(argcnt+3)*sizeof(cell),tags,numtags,fpublic,fconst,chkshadow,&arg);
|
doarg(name,ident,(argcnt+3)*sizeof(cell),tags,numtags,fpublic,fconst,!!(sym->dim.arglist[argcnt].usage & uWRITTEN),chkshadow,&arg);
|
||||||
if (fpublic && arg.hasdefault)
|
if (fpublic && arg.hasdefault)
|
||||||
error(59,name); /* arguments of a public function may not have a default value */
|
error(59,name); /* arguments of a public function may not have a default value */
|
||||||
if ((sym->usage & uPROTOTYPED)==0) {
|
if ((sym->usage & uPROTOTYPED)==0) {
|
||||||
@ -4135,7 +4155,7 @@ static int declargs(symbol *sym,int chkshadow)
|
|||||||
* The arguments themselves are never public.
|
* The arguments themselves are never public.
|
||||||
*/
|
*/
|
||||||
static void doarg(char *name,int ident,int offset,int tags[],int numtags,
|
static void doarg(char *name,int ident,int offset,int tags[],int numtags,
|
||||||
int fpublic,int fconst,int chkshadow,arginfo *arg)
|
int fpublic,int fconst,int written,int chkshadow,arginfo *arg)
|
||||||
{
|
{
|
||||||
symbol *argsym;
|
symbol *argsym;
|
||||||
constvalue_root *enumroot=NULL;
|
constvalue_root *enumroot=NULL;
|
||||||
@ -4229,6 +4249,7 @@ static void doarg(char *name,int ident,int offset,int tags[],int numtags,
|
|||||||
} /* if */
|
} /* if */
|
||||||
arg->ident=(char)ident;
|
arg->ident=(char)ident;
|
||||||
arg->usage=(char)(fconst ? uCONST : 0);
|
arg->usage=(char)(fconst ? uCONST : 0);
|
||||||
|
arg->usage|=(char)(written ? uWRITTEN : 0);
|
||||||
arg->numtags=numtags;
|
arg->numtags=numtags;
|
||||||
arg->tags=(int*)malloc(numtags*sizeof tags[0]);
|
arg->tags=(int*)malloc(numtags*sizeof tags[0]);
|
||||||
if (arg->tags==NULL)
|
if (arg->tags==NULL)
|
||||||
|
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
'test_type': 'output_check',
|
||||||
|
'errors': """
|
||||||
|
share_arg_flags_fstates_gh_371.pwn(1) : warning 214: possibly a "const" array argument was intended: "str"
|
||||||
|
share_arg_flags_fstates_gh_371.pwn(7) : warning 214: possibly a "const" array argument was intended: "str"
|
||||||
|
"""
|
||||||
|
}
|
55
source/compiler/tests/share_arg_flags_fstates_gh_371.pwn
Normal file
55
source/compiler/tests/share_arg_flags_fstates_gh_371.pwn
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
f0(str[]) <fstate : a>
|
||||||
|
{
|
||||||
|
new a = str[0];
|
||||||
|
#pragma unused a
|
||||||
|
}
|
||||||
|
|
||||||
|
f0(str[]) <fstate : b>
|
||||||
|
{
|
||||||
|
new a = str[0] + str[1];
|
||||||
|
#pragma unused a
|
||||||
|
}
|
||||||
|
|
||||||
|
f1(str[]) <fstate : a>
|
||||||
|
{
|
||||||
|
new a = str[0];
|
||||||
|
#pragma unused a
|
||||||
|
}
|
||||||
|
|
||||||
|
f1(str[]) <fstate : b>
|
||||||
|
{
|
||||||
|
str[0] = 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
f2(const str[]) <fstate : a>
|
||||||
|
{
|
||||||
|
new a = str[0];
|
||||||
|
#pragma unused a
|
||||||
|
}
|
||||||
|
|
||||||
|
f2(const str[]) <fstate : b>
|
||||||
|
{
|
||||||
|
new a = str[0] + str[1];
|
||||||
|
#pragma unused a
|
||||||
|
}
|
||||||
|
|
||||||
|
f3(str[]) <fstate : a>
|
||||||
|
{
|
||||||
|
str[0] = 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
f3(str[]) <fstate : b>
|
||||||
|
{
|
||||||
|
new a = str[0];
|
||||||
|
#pragma unused a
|
||||||
|
}
|
||||||
|
|
||||||
|
main()
|
||||||
|
{
|
||||||
|
state fstate : a;
|
||||||
|
new arr[10];
|
||||||
|
f0(arr);
|
||||||
|
f1(arr);
|
||||||
|
f2(arr);
|
||||||
|
f3(arr);
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user