Fix failing assertion with backslash at EOF in macro arguments (#1634)

`Expansion::advance()` can increase its offset beyond the size,
so I don't think this assumption was valid in the first place;
`BufferedContent::advance()` should be able to as well.
This commit is contained in:
Rangi
2025-01-28 21:51:11 -05:00
committed by GitHub
parent a59867cd78
commit c19ddc80f0
12 changed files with 49 additions and 5 deletions

View File

@@ -0,0 +1,3 @@
assert !strcmp("{FOO}", "hello")
assert !strcmp("{DEFINED}", "1")
def FOO equ 42

View File

@@ -0,0 +1,3 @@
error: command-line-symbols.asm(3):
'FOO' already defined at <command-line>
error: Assembly aborted (1 error)!

View File

@@ -0,0 +1 @@
-Weverything -DFOO=hello -DDEFINED

View File

@@ -41,6 +41,9 @@ for {s}, 3, 30, 3
print "{d:x} "
endr
println "-> {d:x}"
for s, 10
println "{d:s}"
endr
for v, 10
println "{d:v}"

View File

@@ -4,7 +4,9 @@ error: for.asm(16):
FOR cannot have a step value of 0
warning: for.asm(20): [-Wbackwards-for]
FOR goes backwards from 1 to 2 by -1
error: for.asm(45) -> for.asm::REPT~4(51):
'v' already defined as constant at for.asm(45) -> for.asm::REPT~4(49)
FATAL: for.asm(45) -> for.asm::REPT~4(51):
error: for.asm(46):
's' already defined as constant at for.asm(39)
error: for.asm(48) -> for.asm::REPT~4(54):
'v' already defined as constant at for.asm(48) -> for.asm::REPT~4(52)
FATAL: for.asm(48) -> for.asm::REPT~4(54):
Failed to update FOR symbol value

View File

@@ -0,0 +1,5 @@
MACRO mac
DEF s EQUS "\#"
println "{#s:s}"
ENDM
mac \\\"\t\r\0\n\{\}\,\(\)\w\

View File

@@ -0,0 +1,5 @@
error: macro-arg-escape-chars.asm(5):
Illegal character escape 'w'
error: macro-arg-escape-chars.asm(5):
Illegal character escape at end of input
error: Assembly aborted (2 errors)!

View File

@@ -0,0 +1 @@
\\\"\t\r\0\n\{},()w\\

View File

@@ -0,0 +1,11 @@
MACRO mac
println "\1"
println \1
ENDM
mac "hello \\\"\t\r\0\n\ ; comment
\wor\
ld"
mac """goodbye
cruel\ ; comment
\nworld"""
mac "\

View File

@@ -0,0 +1,9 @@
error: string-literal-macro-arg.asm(6):
Illegal character escape 'w'
error: string-literal-macro-arg.asm(11):
Illegal character escape at end of input
error: string-literal-macro-arg.asm(11):
Unterminated string
error: string-literal-macro-arg.asm(11) -> string-literal-macro-arg.asm::mac(4):
Unterminated string
error: Assembly aborted (4 errors)!

Binary file not shown.