diff options
author | H. Peter Anvin <hpa@linux.intel.com> | 2016-05-09 14:10:32 -0700 |
---|---|---|
committer | H. Peter Anvin <hpa@linux.intel.com> | 2016-05-09 14:10:32 -0700 |
commit | 3736895c07537856b3ce035258485dd5cfd8af9a (patch) | |
tree | e0ebc3789bde22bf1281c04ba78d71e5f94e5bf2 | |
parent | 4def1a8db462548f60b3b5b44c2ee585c21af9e0 (diff) | |
download | nasm-3736895c07537856b3ce035258485dd5cfd8af9a.tar.gz |
Fix and clean up listing of macro expansion
Fix the printing of the macro stack: we need to follow the
mstk->next_active list, not mstk->next, and we need to reverse the
order so that the highest-level inclusion comes first.
Since this should be a rare or at least performance-insensitive
operation, do it using simple function recursion.
Finally, add an ellipsis before the "from macro" message; it greatly
enhances readability.
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
-rw-r--r-- | preproc.c | 24 | ||||
-rw-r--r-- | test/macroerr.asm | 1 |
2 files changed, 17 insertions, 8 deletions
@@ -5243,9 +5243,23 @@ static void make_tok_num(Token * tok, int64_t val) tok->type = TOK_NUMBER; } +static void pp_list_one_macro(MMacro *m, int severity) +{ + if (!m) + return; + + /* We need to print the next_active list in reverse order */ + pp_list_one_macro(m->next_active, severity); + + if (m->name && !m->nolist) { + src_set_linnum(m->xline + m->lineno); + src_set_fname(m->fname); + nasm_error(severity, "... from macro `%s' defined here", m->name); + } +} + static void pp_error_list_macros(int severity) { - MMacro *m; int32_t saved_line; const char *saved_fname = NULL; @@ -5253,13 +5267,7 @@ static void pp_error_list_macros(int severity) saved_line = src_get_linnum(); saved_fname = src_get_fname(); - list_for_each(m, istk->mstk) { - if (m->name && !m->nolist) { - src_set_linnum(m->xline + m->lineno); - src_set_fname(m->fname); - nasm_error(severity, "from macro `%s' defined here", m->name); - } - } + pp_list_one_macro(istk->mstk, severity); src_set_fname((char *)saved_fname); src_set_linnum(saved_line); diff --git a/test/macroerr.asm b/test/macroerr.asm index 5f1c93e2..d1be751c 100644 --- a/test/macroerr.asm +++ b/test/macroerr.asm @@ -2,6 +2,7 @@ %macro bluttan 1 mov eax,%1 + blej %1 %endmacro bluttan ptr |