ref: e098bf47bae28c2e0ed83291b5ddde35b1da0c26
parent: 190678107bc79a19ce787ce94233661ae1dc45ef
author: ISSOtm <[email protected]>
date: Tue Apr 7 16:56:49 EDT 2020
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.
--- a/src/asm/symbol.c
+++ b/src/asm/symbol.c
@@ -293,23 +293,17 @@
* 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;
}
/*
--- /dev/null
+++ b/test/asm/ref-override.asm
@@ -1,0 +1,4 @@
+SECTION "Test", ROM0[0]
+ db CONSTANT
+
+CONSTANT equ 42
--- /dev/null
+++ b/test/asm/ref-override.out.bin
@@ -1,0 +1,1 @@
+*
\ No newline at end of file