#pragma nodestruct var, names

This commit is contained in:
Y_Less 2018-10-04 13:59:30 +02:00
parent 35fa8d4485
commit 4dd38ffd82
3 changed files with 29 additions and 1 deletions

View File

@ -232,6 +232,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

@ -4962,7 +4962,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

@ -1268,6 +1268,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) {