ref: 122f5fe12e69bf66d89d22b639e162f63f6a95a9
parent: d6a43f6a53b129866a657b6c32c1cc0de59e20f8
author: ISSOtm <[email protected]>
date: Sun Nov 3 22:34:18 EST 2019
Prevent creating labels outside of sections This doesn't make sense, and causes RGBLINK to misbehave
--- a/src/asm/symbol.c
+++ b/src/asm/symbol.c
@@ -634,6 +634,10 @@
nsym->pScope = scope;
nsym->pSection = pCurrentSection;
+ /* Labels need to be assigned a section, except PC */
+ if (!pCurrentSection && strcmp(tzSym, "@"))
+ yyerror("Label \"%s\" created outside of a SECTION",
+ tzSym);
updateSymbolFilename(nsym);
}
--- a/test/asm/label-macro-arg.out
+++ b/test/asm/label-macro-arg.out
@@ -1,4 +1,7 @@
ERROR: label-macro-arg.asm(45) -> label-macro-arg.asm::test_char(31):
+ Label "sizeof_" created outside of a SECTION
+while expanding symbol "VAR_DEF"
+ERROR: label-macro-arg.asm(45) -> label-macro-arg.asm::test_char(31):
Macro 'something' not defined
$5
$6
--- /dev/null
+++ b/test/asm/label-outside-section.asm
@@ -1,0 +1,4 @@
+bad:
+SECTION "Test", ROM0
+good:
+ PRINTT "OK!\n"
--- /dev/null
+++ b/test/asm/label-outside-section.out
@@ -1,0 +1,4 @@
+ERROR: label-outside-section.asm(1):
+ Label "bad" created outside of a SECTION
+error: Assembly aborted (1 errors)!
+OK!
--- a/test/asm/line-continuation-whitespace.out
+++ b/test/asm/line-continuation-whitespace.out
@@ -1,0 +1,3 @@
+ERROR: line-continuation-whitespace.asm(7):
+ Label "foo" created outside of a SECTION
+error: Assembly aborted (1 errors)!
--- a/test/asm/line-continuation.out
+++ b/test/asm/line-continuation.out
@@ -1,0 +1,3 @@
+ERROR: line-continuation.asm(7):
+ Label "foo" created outside of a SECTION
+error: Assembly aborted (1 errors)!
--- a/test/asm/[email protected]
+++ b/test/asm/[email protected]
@@ -1,2 +1,4 @@
ERROR: [email protected](1):
+ Label "foo" created outside of a SECTION
+ERROR: [email protected](1):
Macro '@' not defined
--- a/test/asm/pops-restore-no-section.out
+++ b/test/asm/pops-restore-no-section.out
@@ -1,2 +1,4 @@
+ERROR: pops-restore-no-section.asm(9):
+ Label "DisallowedContent" created outside of a SECTION
ERROR: pops-restore-no-section.asm(10):
Code generation before SECTION directive