mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 10:12:06 +00:00
Check if parent exists for local label reference
If an attempt is made to reference a local label before any non-local label is defined, raise an error instead of segfaulting.
This commit is contained in:
@@ -735,6 +735,9 @@ void sym_Ref(char *tzSym)
|
|||||||
int isLocal = 0;
|
int isLocal = 0;
|
||||||
|
|
||||||
if (*tzSym == '.') {
|
if (*tzSym == '.') {
|
||||||
|
if (!pScope)
|
||||||
|
fatalerror("Local label reference '%s' in main scope",
|
||||||
|
tzSym);
|
||||||
fullSymbolName(fullname, sizeof(fullname), tzSym,
|
fullSymbolName(fullname, sizeof(fullname), tzSym,
|
||||||
pScope);
|
pScope);
|
||||||
tzSym = fullname;
|
tzSym = fullname;
|
||||||
|
|||||||
3
test/asm/local-ref-without-parent.asm
Normal file
3
test/asm/local-ref-without-parent.asm
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
SECTION "sec", ROM0
|
||||||
|
|
||||||
|
dw .test
|
||||||
2
test/asm/local-ref-without-parent.out
Normal file
2
test/asm/local-ref-without-parent.out
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
ERROR: local-ref-without-parent.asm(3):
|
||||||
|
Local label reference '.test' in main scope
|
||||||
2
test/asm/local-ref-without-parent.out.pipe
Normal file
2
test/asm/local-ref-without-parent.out.pipe
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
ERROR: -(3):
|
||||||
|
Local label reference '.test' in main scope
|
||||||
Reference in New Issue
Block a user