From 09b2a4e3df4728349446bdc3dd686ab8cc3d7b60 Mon Sep 17 00:00:00 2001 From: Keith Kanios Date: Mon, 9 Aug 2010 22:34:19 -0500 Subject: [PATCH] preproc.c: fixed macro-relative line number handling for warning/error/fatal --- preproc.c | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/preproc.c b/preproc.c index c487b5ff..bdaf45dc 100644 --- a/preproc.c +++ b/preproc.c @@ -252,6 +252,7 @@ struct ExpInv { bool emitting; int lineno; /* current line number in expansion */ int linnum; /* line number at invocation */ + int relno; /* relative line number at invocation */ }; /* @@ -1389,6 +1390,15 @@ static ExpInv *new_ExpInv(int exp_type, ExpDef *ed) } else { ei->linnum = -1; } + if ((istk->expansion == NULL) || + (ei->type == EXP_MMACRO)) { + ei->relno = 0; + } else { + ei->relno = istk->expansion->lineno; + if (ed != NULL) { + ei->relno -= (ed->linecount + 1); + } + } return ei; } @@ -4940,12 +4950,18 @@ static void verror(int severity, const char *fmt, va_list arg) vsnprintf(buff, sizeof(buff), fmt, arg); - if ((istk != NULL) && - (istk->expansion != NULL) && - (istk->expansion->type == EXP_MMACRO)) { - ExpDef *ed = istk->expansion->def; - nasm_error(severity, "(%s:%d) %s", ed->name, - istk->expansion->lineno, buff); + if ((istk != NULL) && (istk->mmac_depth > 0)) { + ExpInv *ei = istk->expansion; + int lineno = ei->lineno; + while (ei != NULL) { + if (ei->type == EXP_MMACRO) { + break; + } + lineno += ei->relno; + ei = ei->prev; + } + nasm_error(severity, "(%s:%d) %s", ei->def->name, + lineno, buff); } else { nasm_error(severity, "%s", buff); } -- 2.11.4.GIT