ref: a6bf77718cc823cc6ca78aefdaa0e21ea72a460f
parent: e33e6e24132dea1490e3039a6c85194d2b6a7a74
author: dbrotz <[email protected]>
date: Tue Aug 20 05:57:53 EDT 2019
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.
--- a/src/asm/symbol.c
+++ b/src/asm/symbol.c
@@ -735,6 +735,9 @@
int isLocal = 0;
if (*tzSym == '.') {
+ if (!pScope)
+ fatalerror("Local label reference '%s' in main scope",
+ tzSym);
fullSymbolName(fullname, sizeof(fullname), tzSym,
pScope);
tzSym = fullname;
--- /dev/null
+++ b/test/asm/local-ref-without-parent.asm
@@ -1,0 +1,3 @@
+SECTION "sec", ROM0
+
+dw .test
--- /dev/null
+++ b/test/asm/local-ref-without-parent.out
@@ -1,0 +1,2 @@
+ERROR: local-ref-without-parent.asm(3):
+ Local label reference '.test' in main scope
--- /dev/null
+++ b/test/asm/local-ref-without-parent.out.pipe
@@ -1,0 +1,2 @@
+ERROR: -(3):
+ Local label reference '.test' in main scope