shithub: rgbds

Download patch

ref: 446173f0cb54ce6f0b5be43e984b6ccde905260c
parent: e27f38184241c192dd1abf0747a5ca220c242d93
parent: e3e18063c657428dd9043bd631595a38be2f4d7c
author: Eldred Habert <[email protected]>
date: Thu Aug 29 16:08:08 EDT 2019

Merge pull request #387 from ISSOtm/set_doesnt_override_equ

Prevent `SET` from overriding constant symbols

--- a/CONTRIBUTORS.rst
+++ b/CONTRIBUTORS.rst
@@ -30,6 +30,8 @@
 
 - David Brotz <[email protected]>
 
+- Eldred Habert <[email protected]>
+
 - The Musl C library <http://www.musl-libc.org>
 
 - obskyr <[email protected]>
--- a/src/asm/symbol.c
+++ b/src/asm/symbol.c
@@ -553,6 +553,11 @@
 					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,
--- /dev/null
+++ b/test/asm/symbol-override.asm
@@ -1,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
--- /dev/null
+++ b/test/asm/symbol-override.out
@@ -1,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
--- /dev/null
+++ b/test/asm/symbol-override.out.pipe
@@ -1,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