mirror of
https://github.com/netwide-assembler/nasm.git
synced 2025-04-12 18:40:23 +08:00
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:
parent
4def1a8db4
commit
3736895c07
24
preproc.c
24
preproc.c
@ -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);
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
%macro bluttan 1
|
||||
mov eax,%1
|
||||
blej %1
|
||||
%endmacro
|
||||
|
||||
bluttan ptr
|
||||
|
Loading…
x
Reference in New Issue
Block a user