summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Kanios <keith@kanios.net>2010-08-09 22:34:19 -0500
committerKeith Kanios <keith@kanios.net>2010-08-09 22:34:19 -0500
commit09b2a4e3df4728349446bdc3dd686ab8cc3d7b60 (patch)
treef02ccfbcf7534cbc077c1e7d918d6f59905dffdb
parent9fb09e75ec63ae2aabc192308cd20477f60f68ad (diff)
downloadnasm-09b2a4e3df4728349446bdc3dd686ab8cc3d7b60.tar.gz
preproc.c: fixed macro-relative line number handling for warning/error/fatal
-rw-r--r--preproc.c28
1 files 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);
}