Merge pull request #377 from Y-Less/Branch_pragma_unwritten
Branch pragma unwritten
This commit is contained in:
commit
599415444b
@ -1238,9 +1238,13 @@ static int command(void)
|
|||||||
sc_tabsize=(int)val;
|
sc_tabsize=(int)val;
|
||||||
} else if (strcmp(str,"align")==0) {
|
} else if (strcmp(str,"align")==0) {
|
||||||
sc_alignnext=TRUE;
|
sc_alignnext=TRUE;
|
||||||
} else if (strcmp(str,"unused")==0) {
|
} else if (strcmp(str,"unused")==0 || strcmp(str,"unread")==0 || strcmp(str,"unwritten")==0) {
|
||||||
char name[sNAMEMAX+1];
|
char name[sNAMEMAX+1];
|
||||||
int i,comma;
|
int i,comma;
|
||||||
|
/* mark as read if the pragma wasn't `unwritten` */
|
||||||
|
int read = str[2] == 'w' ? 0 : uREAD;
|
||||||
|
/* mark as written if the pragma wasn't `unread` */
|
||||||
|
int write = str[2] == 'r' ? 0 : uWRITTEN;
|
||||||
symbol *sym;
|
symbol *sym;
|
||||||
do {
|
do {
|
||||||
/* get the name */
|
/* get the name */
|
||||||
@ -1254,10 +1258,11 @@ static int command(void)
|
|||||||
if (sym==NULL)
|
if (sym==NULL)
|
||||||
sym=findglb(name,sSTATEVAR);
|
sym=findglb(name,sSTATEVAR);
|
||||||
if (sym!=NULL) {
|
if (sym!=NULL) {
|
||||||
sym->usage |= uREAD;
|
/* mark as read if the pragma wasn't `unwritten` */
|
||||||
|
sym->usage |= read;
|
||||||
if (sym->ident==iVARIABLE || sym->ident==iREFERENCE
|
if (sym->ident==iVARIABLE || sym->ident==iREFERENCE
|
||||||
|| sym->ident==iARRAY || sym->ident==iREFARRAY)
|
|| sym->ident==iARRAY || sym->ident==iREFARRAY)
|
||||||
sym->usage |= uWRITTEN;
|
sym->usage |= write;
|
||||||
} else {
|
} else {
|
||||||
error(17,name); /* undefined symbol */
|
error(17,name); /* undefined symbol */
|
||||||
} /* if */
|
} /* if */
|
||||||
|
5
source/compiler/tests/gh_373.meta
Normal file
5
source/compiler/tests/gh_373.meta
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
'test_type': 'output_check',
|
||||||
|
'errors': """
|
||||||
|
"""
|
||||||
|
}
|
11
source/compiler/tests/gh_373.pwn
Normal file
11
source/compiler/tests/gh_373.pwn
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
Func(a[])
|
||||||
|
{
|
||||||
|
#pragma unwritten a
|
||||||
|
return a[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
main() {
|
||||||
|
new a[2];
|
||||||
|
Func(a);
|
||||||
|
}
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user