Disable EQUS expansion for raw symbols (by parsing them as strings) (#1648)

This commit is contained in:
Rangi
2025-02-15 10:44:51 +01:00
committed by GitHub
parent 3feb75f84f
commit b2e865ee2a
8 changed files with 206 additions and 17 deletions

View File

@@ -0,0 +1,29 @@
def n equ 42
def s equs "hello"
macro m
endm
assert (#n) == 42
assert (#s) == $656c6c6f
assert (#m) == 0
assert (#u) == 0
assert strlen(#n) == 0
assert strlen(#s) == 5
assert strlen(#m) == 0
assert strlen(#u) == 0
def d_n = (#n)
def d_s = (#s)
def d_m = (#m)
def d_u = (#u)
def s_n equs #n
def s_s equs #s
def s_m equs #m
def s_u equs #u
purge #s
purge #s
assert (#s) == 0
assert strlen(#s) == 0

View File

@@ -0,0 +1,27 @@
warning: raw-string-symbol-errors.asm(7): [-Wobsolete]
Treating multi-unit strings as numbers is deprecated
error: raw-string-symbol-errors.asm(8):
'm' is not a numeric symbol
error: raw-string-symbol-errors.asm(11):
'n' is not a string symbol
error: raw-string-symbol-errors.asm(13):
'm' is not a string symbol
error: raw-string-symbol-errors.asm(14):
'u' is not a string symbol
warning: raw-string-symbol-errors.asm(17): [-Wobsolete]
Treating multi-unit strings as numbers is deprecated
error: raw-string-symbol-errors.asm(18):
'm' is not a numeric symbol
error: raw-string-symbol-errors.asm(19):
Expected constant expression: 'u' is not constant at assembly time
error: raw-string-symbol-errors.asm(21):
'n' is not a string symbol
error: raw-string-symbol-errors.asm(23):
'm' is not a string symbol
error: raw-string-symbol-errors.asm(24):
'u' is not a string symbol
error: raw-string-symbol-errors.asm(27):
's' was already purged
error: raw-string-symbol-errors.asm(29):
's' is not a string symbol
error: Assembly aborted (11 errors)!

View File

@@ -0,0 +1,34 @@
opt Wno-unmapped-char
def hello equs "world"
def name equs "hello"
println "{name}"
println #name
assert !strcmp(strsub(#name, 1, 4), "hell")
assert strlen(#hello) == charlen(#hello)
assert strlen("{hello}") == 5
def multi equs """the quick
brown fox"""
println #multi
def char equs "A"
def n = #char
println n
def n = (#char)
println n
def n = 1 + #char
println n
assert #char == $41
def fmt equs "%s %s %d"
println strfmt(#fmt, #name, #hello, (#char))
purge #name
assert !def(name) && !def(#name) && def(hello)
section "test", rom0
#label:
db #hello
dw #hello
dw BANK(#label), #label

View File

@@ -0,0 +1,8 @@
hello
hello
the quick
brown fox
$41
$41
$42
hello world 65

Binary file not shown.