mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 10:12:06 +00:00
Fix bug where macro names can be treated as numeric symbols (#1653)
This commit is contained in:
@@ -75,6 +75,9 @@ void Expression::makeSymbol(std::string const &symName) {
|
||||
if (Symbol *sym = sym_FindScopedSymbol(symName); sym_IsPC(sym) && !sect_GetSymbolSection()) {
|
||||
error("PC has no value outside of a section\n");
|
||||
data = 0;
|
||||
} else if (sym && !sym->isNumeric() && !sym->isLabel()) {
|
||||
error("'%s' is not a numeric symbol\n", symName.c_str());
|
||||
data = 0;
|
||||
} else if (!sym || !sym->isConstant()) {
|
||||
isSymbol = true;
|
||||
|
||||
|
||||
11
test/asm/non-numeric-symbol.asm
Normal file
11
test/asm/non-numeric-symbol.asm
Normal file
@@ -0,0 +1,11 @@
|
||||
MACRO mac
|
||||
ENDM
|
||||
|
||||
DEF n EQU mac
|
||||
DEF v = 2 + mac
|
||||
DEF k RB mac * 2
|
||||
|
||||
SECTION "test", ROM0
|
||||
db mac
|
||||
dw 2 + mac
|
||||
dl mac * 2
|
||||
13
test/asm/non-numeric-symbol.err
Normal file
13
test/asm/non-numeric-symbol.err
Normal file
@@ -0,0 +1,13 @@
|
||||
error: non-numeric-symbol.asm(4):
|
||||
'mac' is not a numeric symbol
|
||||
error: non-numeric-symbol.asm(5):
|
||||
'mac' is not a numeric symbol
|
||||
error: non-numeric-symbol.asm(6):
|
||||
'mac' is not a numeric symbol
|
||||
error: non-numeric-symbol.asm(9):
|
||||
'mac' is not a numeric symbol
|
||||
error: non-numeric-symbol.asm(10):
|
||||
'mac' is not a numeric symbol
|
||||
error: non-numeric-symbol.asm(11):
|
||||
'mac' is not a numeric symbol
|
||||
error: Assembly aborted (6 errors)!
|
||||
Reference in New Issue
Block a user