Merge pull request #378 from Y-Less/Branch_pragma_nodestruct

Branch pragma nodestruct
This commit is contained in:
Zeex 2019-06-17 10:58:07 +06:00 committed by GitHub
commit c9b3e44bcb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 44 additions and 1 deletions

View File

@ -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.

View File

@ -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;

View File

@ -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) {

View File

@ -0,0 +1,6 @@
{
'test_type': 'output_check',
'errors': """
gh_258.pwn(10) : warning 203: symbol is never used: "operator~(Tag:)"
"""
}

View File

@ -0,0 +1,9 @@
operator~(Tag:var[], size) {
}
main() {
new Tag:a;
#pragma unused a
#pragma nodestruct a
}