[Nasm-commits] [nasm:preproc-rewrite] preproc.c: fixed macro-relative line number handling for warning/error/fatal

nasm-bot for Keith Kanios keith at kanios.net
Thu Jun 4 19:56:30 PDT 2020


Commit-ID:  09b2a4e3df4728349446bdc3dd686ab8cc3d7b60
Gitweb:     http://repo.or.cz/w/nasm.git?a=commitdiff;h=09b2a4e3df4728349446bdc3dd686ab8cc3d7b60
Author:     Keith Kanios <keith at kanios.net>
AuthorDate: Mon, 9 Aug 2010 22:34:19 -0500
Committer:  Keith Kanios <keith at kanios.net>
CommitDate: Mon, 9 Aug 2010 22:34:19 -0500

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);
 	}


More information about the Nasm-commits mailing list