diff --git a/source/compiler/sc.h b/source/compiler/sc.h index 093b8c3..4b9ed03 100644 --- a/source/compiler/sc.h +++ b/source/compiler/sc.h @@ -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. diff --git a/source/compiler/sc1.c b/source/compiler/sc1.c index c63a653..2fe3934 100644 --- a/source/compiler/sc1.c +++ b/source/compiler/sc1.c @@ -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; diff --git a/source/compiler/sc2.c b/source/compiler/sc2.c index 866d622..671a04c 100644 --- a/source/compiler/sc2.c +++ b/source/compiler/sc2.c @@ -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; iusage |= 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) { diff --git a/source/compiler/tests/gh_258.meta b/source/compiler/tests/gh_258.meta new file mode 100644 index 0000000..c583575 --- /dev/null +++ b/source/compiler/tests/gh_258.meta @@ -0,0 +1,6 @@ +{ + 'test_type': 'output_check', + 'errors': """ + gh_258.pwn(10) : warning 203: symbol is never used: "operator~(Tag:)" + """ +} diff --git a/source/compiler/tests/gh_258.pwn b/source/compiler/tests/gh_258.pwn new file mode 100644 index 0000000..a0a2174 --- /dev/null +++ b/source/compiler/tests/gh_258.pwn @@ -0,0 +1,9 @@ +operator~(Tag:var[], size) { +} + +main() { + new Tag:a; + #pragma unused a + #pragma nodestruct a +} +