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>
This commit is contained in:
H. Peter Anvin 2016-05-09 14:10:32 -07:00
parent 4def1a8db4
commit 3736895c07
2 changed files with 17 additions and 8 deletions

View File

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

View File

@ -2,6 +2,7 @@
%macro bluttan 1
mov eax,%1
blej %1
%endmacro
bluttan ptr