Allow references to be overridden by constant symbols

RGBLINK is capable of handling it now.
Though it'd be ideal for RGBASM to directly catch it.

Fixes #496.
This commit is contained in:
ISSOtm
2020-04-07 20:56:49 +02:00
parent 190678107b
commit e098bf47ba
5 changed files with 13 additions and 14 deletions

View File

@@ -293,23 +293,17 @@ struct sSymbol *sym_FindMacro(char const *s)
* hasn't already been defined or referenced in a context that would
* require that it be relocatable
*/
static struct sSymbol *createNonrelocSymbol(char const *tzSym)
static struct sSymbol *createNonrelocSymbol(char const *symbolName)
{
struct sSymbol *nsym = findsymbol(tzSym, NULL);
struct sSymbol *symbol = findsymbol(symbolName, NULL);
if (nsym != NULL) {
if (sym_IsDefined(nsym)) {
yyerror("'%s' already defined at %s(%u)",
tzSym, nsym->tzFileName, nsym->nFileLine);
} else {
yyerror("'%s' referenced as label at %s(%u)",
tzSym, nsym->tzFileName, nsym->nFileLine);
}
} else {
nsym = createsymbol(tzSym);
}
if (!symbol)
symbol = createsymbol(symbolName);
else if (sym_IsDefined(symbol))
yyerror("'%s' already defined at %s(%u)", symbolName,
symbol->tzFileName, symbol->nFileLine);
return nsym;
return symbol;
}
/*

View File

@@ -0,0 +1,4 @@
SECTION "Test", ROM0[0]
db CONSTANT
CONSTANT equ 42

View File

View File

View File

@@ -0,0 +1 @@
*