Merge pull request #378 from Y-Less/Branch_pragma_nodestruct
Branch pragma nodestruct
This commit is contained in:
commit
c9b3e44bcb
@ -236,6 +236,7 @@ typedef struct s_symbol {
|
||||
#define uENUMFIELD 0x040
|
||||
#define uMISSING 0x080
|
||||
#define uFORWARD 0x100
|
||||
#define uNODESTRUCT 0x200 /* "no destruct(or)", not "node struct" */
|
||||
/* 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.
|
||||
|
@ -4971,7 +4971,7 @@ static void destructsymbols(symbol *root,int level)
|
||||
int savepri=FALSE;
|
||||
symbol *sym=root->next;
|
||||
while (sym!=NULL && sym->compound>=level) {
|
||||
if ((sym->ident==iVARIABLE || sym->ident==iARRAY) && !(sym->vclass==sSTATIC && sym->fnumber==-1)) {
|
||||
if ((sym->ident==iVARIABLE || sym->ident==iARRAY) && !(sym->vclass==sSTATIC && sym->fnumber==-1) && !(sym->usage&uNODESTRUCT)) {
|
||||
char symbolname[16];
|
||||
symbol *opsym;
|
||||
cell elements;
|
||||
|
@ -1273,6 +1273,33 @@ static int command(void)
|
||||
if (comma)
|
||||
lptr++;
|
||||
} while (comma);
|
||||
} else if (strcmp(str,"nodestruct")==0) {
|
||||
char name[sNAMEMAX+1];
|
||||
int i,comma;
|
||||
symbol *sym;
|
||||
do {
|
||||
/* get the name */
|
||||
while (*lptr<=' ' && *lptr!='\0')
|
||||
lptr++;
|
||||
for (i=0; i<sizeof name && alphanum(*lptr); i++,lptr++)
|
||||
name[i]=*lptr;
|
||||
name[i]='\0';
|
||||
/* get the symbol */
|
||||
sym=findloc(name);
|
||||
if (sym==NULL)
|
||||
sym=findglb(name,sSTATEVAR);
|
||||
if (sym!=NULL) {
|
||||
sym->usage |= uNODESTRUCT;
|
||||
} else {
|
||||
error(17,name); /* undefined symbol */
|
||||
} /* if */
|
||||
/* see if a comma follows the name */
|
||||
while (*lptr<=' ' && *lptr!='\0')
|
||||
lptr++;
|
||||
comma= (*lptr==',');
|
||||
if (comma)
|
||||
lptr++;
|
||||
} while (comma);
|
||||
} else if (strcmp(str,"naked")==0) {
|
||||
pc_naked=TRUE;
|
||||
} else if (strcmp(str,"warning")==0) {
|
||||
|
6
source/compiler/tests/gh_258.meta
Normal file
6
source/compiler/tests/gh_258.meta
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
'test_type': 'output_check',
|
||||
'errors': """
|
||||
gh_258.pwn(10) : warning 203: symbol is never used: "operator~(Tag:)"
|
||||
"""
|
||||
}
|
9
source/compiler/tests/gh_258.pwn
Normal file
9
source/compiler/tests/gh_258.pwn
Normal file
@ -0,0 +1,9 @@
|
||||
operator~(Tag:var[], size) {
|
||||
}
|
||||
|
||||
main() {
|
||||
new Tag:a;
|
||||
#pragma unused a
|
||||
#pragma nodestruct a
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user