Fix local sym names not being expanded by PURGE

And an additional bug that broke the attached test
This commit is contained in:
ISSOtm
2020-05-03 19:06:48 +02:00
parent 12693081c9
commit c135e2c6a0
5 changed files with 19 additions and 2 deletions

View File

@@ -208,7 +208,7 @@ void sym_Purge(char const *symName)
yyerror("Symbol \"%s\" is referenced and thus cannot be purged",
symName);
} else {
hash_RemoveElement(symbols, symName);
hash_RemoveElement(symbols, symbol->name);
if (symbol->type == SYM_MACRO)
free(symbol->macro);
free(symbol);
@@ -476,11 +476,14 @@ struct Symbol *sym_Ref(char const *symName)
if (nsym == NULL) {
char fullname[MAXSYMLEN + 1];
struct Symbol const *scope = NULL;
if (*symName == '.') {
if (symName[0] == '.') {
if (!symbolScope)
fatalerror("Local label reference '%s' in main scope",
symName);
scope = symbolScope->scope ? symbolScope->scope
: symbolScope;
fullSymbolName(fullname, sizeof(fullname), symName,
symbolScope);
symName = fullname;
@@ -488,6 +491,7 @@ struct Symbol *sym_Ref(char const *symName)
nsym = createsymbol(symName);
nsym->type = SYM_REF;
nsym->scope = scope;
}
return nsym;