summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH. Peter Anvin (Intel) <hpa@zytor.com>2019-10-16 14:51:16 -0700
committerH. Peter Anvin (Intel) <hpa@zytor.com>2019-10-16 14:51:16 -0700
commite86fa7fffd1789e3b9b2c584d4401dbb6fc92186 (patch)
tree37748bbff8643a76f53f0e43c5ec860fca687dbb
parent84b852bff0ee7085245defbeb38d6218052579ae (diff)
downloadnasm-e86fa7fffd1789e3b9b2c584d4401dbb6fc92186.tar.gz
preproc: %xdefine must process arguments before expanding
The only way in which %xdefine(xxx) yyyy zzzz differs from %define(xxx) yyyy %[zzzz] is that in the former case macro arguments get preserved, even if they are macros defined elsewhere. Revert to that behavior. Reported-by: C. Masloch <pushbx@ulukai.org> Link: https://bugzilla.nasm.us/show_bug.cgi?id=3392623 Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
-rw-r--r--asm/preproc.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/asm/preproc.c b/asm/preproc.c
index 14a73885..785d6e30 100644
--- a/asm/preproc.c
+++ b/asm/preproc.c
@@ -4027,10 +4027,6 @@ issue_error:
free_tlist(tt);
tmpl.alias = true;
} else {
- /* Expand the macro definition now for %xdefine and %ixdefine */
- if (i == PP_XDEFINE)
- tline = expand_smacro(tline);
-
/* Reverse expansion list and mark parameter tokens */
macro_start = NULL;
t = tline;
@@ -4051,6 +4047,18 @@ issue_error:
macro_start = t;
t = tt;
}
+
+ /*
+ * Expand the macro definition now for %xdefine and %ixdefine.
+ * This is done AFTER marking of parameter tokens: this is the
+ * only way in which %xdefine(xxx) yyyy zzzz differs from
+ * %define(xxx) yyyy %[zzzz]
+ */
+ if (i == PP_XDEFINE) {
+ tline = reverse_tokens(tline);
+ tline = expand_smacro(tline);
+ tline = reverse_tokens(tline);
+ }
}
/*