Prevent SET from overriding constant symbols

Fixes #341
This commit is contained in:
ISSOtm
2019-08-27 21:07:42 +02:00
parent e33e6e2413
commit e3e18063c6
5 changed files with 37 additions and 0 deletions

View File

@@ -30,6 +30,8 @@ Other contributors
- David Brotz <dbrotz007@gmail.com>
- Eldred Habert <eldredhabert0@gmail.com>
- The Musl C library <http://www.musl-libc.org>
- obskyr <powpowd@gmail.com>

View File

@@ -553,6 +553,11 @@ void sym_AddSet(char *tzSym, int32_t value)
tzSym,
nsym->tzFileName,
nsym->nFileLine);
else if (!(nsym->nType & SYMF_SET))
yyerror("'%s' already defined as constant at %s(%u)",
tzSym,
nsym->tzFileName,
nsym->nFileLine);
} else if (nsym->nType & SYMF_REF) {
yyerror("'%s' already referenced at %s(%u)",
tzSym,

View File

@@ -0,0 +1,14 @@
V set 0
V set 1
PRINTT "V={V}\n"
W equ 1
W set 0
rsset 1
X rb 0
X set 0
SECTION "Test", ROM0[1]
Y:
Y set 0

View File

@@ -0,0 +1,8 @@
ERROR: symbol-override.asm(6):
'W' already defined as constant at symbol-override.asm(5)
ERROR: symbol-override.asm(10):
'X' already defined as constant at symbol-override.asm(9)
ERROR: symbol-override.asm(14):
'Y' already defined as non-constant at symbol-override.asm(13)
error: Assembly aborted (3 errors)!
V=$1

View File

@@ -0,0 +1,8 @@
ERROR: -(6):
'W' already defined as constant at -(5)
ERROR: -(10):
'X' already defined as constant at -(9)
ERROR: -(14):
'Y' already defined as non-constant at -(13)
error: Assembly aborted (3 errors)!
V=$1