diff --git a/src/asm/symbol.c b/src/asm/symbol.c index 60431c0a..bf9d9942 100644 --- a/src/asm/symbol.c +++ b/src/asm/symbol.c @@ -735,6 +735,9 @@ void sym_Ref(char *tzSym) int isLocal = 0; if (*tzSym == '.') { + if (!pScope) + fatalerror("Local label reference '%s' in main scope", + tzSym); fullSymbolName(fullname, sizeof(fullname), tzSym, pScope); tzSym = fullname; diff --git a/test/asm/local-ref-without-parent.asm b/test/asm/local-ref-without-parent.asm new file mode 100644 index 00000000..717b9ff0 --- /dev/null +++ b/test/asm/local-ref-without-parent.asm @@ -0,0 +1,3 @@ +SECTION "sec", ROM0 + +dw .test diff --git a/test/asm/local-ref-without-parent.out b/test/asm/local-ref-without-parent.out new file mode 100644 index 00000000..fd784ef3 --- /dev/null +++ b/test/asm/local-ref-without-parent.out @@ -0,0 +1,2 @@ +ERROR: local-ref-without-parent.asm(3): + Local label reference '.test' in main scope diff --git a/test/asm/local-ref-without-parent.out.pipe b/test/asm/local-ref-without-parent.out.pipe new file mode 100644 index 00000000..9f630009 --- /dev/null +++ b/test/asm/local-ref-without-parent.out.pipe @@ -0,0 +1,2 @@ +ERROR: -(3): + Local label reference '.test' in main scope