Prevent creating labels outside of sections

This doesn't make sense, and causes RGBLINK to misbehave
This commit is contained in:
ISSOtm
2019-11-04 03:34:18 +01:00
parent d6a43f6a53
commit 122f5fe12e
8 changed files with 25 additions and 0 deletions

View File

@@ -634,6 +634,10 @@ void sym_AddReloc(char *tzSym)
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);
}

View File

@@ -1,3 +1,6 @@
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

View File

@@ -0,0 +1,4 @@
bad:
SECTION "Test", ROM0
good:
PRINTT "OK!\n"

View File

@@ -0,0 +1,4 @@
ERROR: label-outside-section.asm(1):
Label "bad" created outside of a SECTION
error: Assembly aborted (1 errors)!
OK!

View File

@@ -0,0 +1,3 @@
ERROR: line-continuation-whitespace.asm(7):
Label "foo" created outside of a SECTION
error: Assembly aborted (1 errors)!

View File

@@ -0,0 +1,3 @@
ERROR: line-continuation.asm(7):
Label "foo" created outside of a SECTION
error: Assembly aborted (1 errors)!

View File

@@ -1,2 +1,4 @@
ERROR: macro-@.asm(1):
Label "foo" created outside of a SECTION
ERROR: macro-@.asm(1):
Macro '@' not defined

View File

@@ -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