diff options
author | Keith Kanios <keith@kanios.net> | 2010-08-09 22:34:19 -0500 |
---|---|---|
committer | Keith Kanios <keith@kanios.net> | 2010-08-09 22:34:19 -0500 |
commit | 09b2a4e3df4728349446bdc3dd686ab8cc3d7b60 (patch) | |
tree | f02ccfbcf7534cbc077c1e7d918d6f59905dffdb | |
parent | 9fb09e75ec63ae2aabc192308cd20477f60f68ad (diff) | |
download | nasm-09b2a4e3df4728349446bdc3dd686ab8cc3d7b60.tar.gz |
preproc.c: fixed macro-relative line number handling for warning/error/fatal
-rw-r--r-- | preproc.c | 28 |
1 files changed, 22 insertions, 6 deletions
@@ -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); } |