ref: 7063f66b2d628c519e11a7a3bddb538f6bc7e6dc
parent: 6e59bcb60efd0aa39bf30d68a387b3def02382ce
parent: 122f5fe12e69bf66d89d22b639e162f63f6a95a9
author: Eldred Habert <[email protected]>
date: Wed Nov 6 03:33:25 EST 2019
Merge pull request #450 from ISSOtm/labels_in_sections Prevent creating labels outside of sections
--- 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