From 8a1e920e23f78e7e96307a45d80b463d34a30cd0 Mon Sep 17 00:00:00 2001 From: ISSOtm Date: Thu, 12 Dec 2019 23:46:10 +0100 Subject: [PATCH] Fix incorrect line counting when running REPT blocks. Fixes #461 --- src/asm/fstack.c | 5 ++--- test/asm/rept-line-no.asm | 8 ++++++++ test/asm/rept-line-no.out | 10 ++++++++++ 3 files changed, 20 insertions(+), 3 deletions(-) create mode 100644 test/asm/rept-line-no.asm create mode 100644 test/asm/rept-line-no.out diff --git a/src/asm/fstack.c b/src/asm/fstack.c index 322c6c3f..28a60943 100644 --- a/src/asm/fstack.c +++ b/src/asm/fstack.c @@ -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__); diff --git a/test/asm/rept-line-no.asm b/test/asm/rept-line-no.asm new file mode 100644 index 00000000..b752d57e --- /dev/null +++ b/test/asm/rept-line-no.asm @@ -0,0 +1,8 @@ + + WARN "Line 2" +REPT 3 + + WARN "Line 5" + +ENDR + WARN "Line 8" diff --git a/test/asm/rept-line-no.out b/test/asm/rept-line-no.out new file mode 100644 index 00000000..8c259aef --- /dev/null +++ b/test/asm/rept-line-no.out @@ -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