Warn about backwards FOR loops with -Wbackwards-for (-Wall)

Fixes #816
This commit is contained in:
Rangi
2021-03-31 10:00:21 -04:00
parent 3741bd4617
commit 49aac2961d
6 changed files with 29 additions and 6 deletions

View File

@@ -8,13 +8,17 @@ for v, 0
endr
for v, 2, 1
print "unreached"
print "backwards"
endr
for v, 1, 2, 0
print "unreached"
endr
for v, 1, 2, -1
print "backwards"
endr
for x, 1, 5+1
print "{d:x} "
endr

View File

@@ -1,6 +1,10 @@
warning: for.asm(12): [-Wbackwards-for]
FOR goes backwards from 2 to 1 by 1
ERROR: for.asm(16):
FOR cannot have a step value of 0
ERROR: for.asm(41) -> for.asm::REPT~4(47):
'v' already defined as constant at for.asm(41) -> for.asm::REPT~4(45)
FATAL: for.asm(41) -> for.asm::REPT~4(47):
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):
Failed to update FOR symbol value