Fix incorrect line counting when running REPT blocks.

Fixes #461
This commit is contained in:
ISSOtm
2019-12-12 23:46:10 +01:00
parent 373762dedc
commit 8a1e920e23
3 changed files with 20 additions and 3 deletions

View File

@@ -163,7 +163,8 @@ static int32_t popcontext(void)
}
yy_delete_buffer(CurrentFlexHandle);
nLineNo = pLastFile->nLine;
nLineNo = nCurrentStatus == STAT_isREPTBlock ? nCurrentREPTBodyLastLine
: pLastFile->nLine;
if (nCurrentStatus == STAT_isInclude)
fclose(pCurrentFile);
@@ -190,8 +191,6 @@ static int32_t popcontext(void)
nCurrentREPTBlockSize = pLastFile->nREPTBlockSize;
nCurrentREPTBlockCount = pLastFile->nREPTBlockCount;
nCurrentREPTBodyFirstLine = pLastFile->nREPTBodyFirstLine;
/* + 1 to account for the `ENDR` line */
nLineNo = pLastFile->nREPTBodyLastLine + 1;
break;
default:
fatalerror("%s: Internal error.", __func__);

View File

@@ -0,0 +1,8 @@
WARN "Line 2"
REPT 3
WARN "Line 5"
ENDR
WARN "Line 8"

10
test/asm/rept-line-no.out Normal file
View File

@@ -0,0 +1,10 @@
warning: rept-line-no.asm(2): [-Wuser]
Line 2
warning: rept-line-no.asm(3) -> rept-line-no.asm::REPT~1(5): [-Wuser]
Line 5
warning: rept-line-no.asm(3) -> rept-line-no.asm::REPT~2(5): [-Wuser]
Line 5
warning: rept-line-no.asm(3) -> rept-line-no.asm::REPT~3(5): [-Wuser]
Line 5
warning: rept-line-no.asm(8): [-Wuser]
Line 8