From d4607846a4e0774aa134b15e8ffe8e3a0a18efa0 Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin (Intel)" Date: Tue, 20 Aug 2019 16:19:37 -0700 Subject: preproc: smacro argument lists can't be preceded by space The smacro argument list cannot be preceded by whitespace, or we wouldn't be able to define no-argument smacros the expansion of which starts with (. Signed-off-by: H. Peter Anvin (Intel) --- asm/preproc.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/asm/preproc.c b/asm/preproc.c index 125fa100..a3f8b7de 100644 --- a/asm/preproc.c +++ b/asm/preproc.c @@ -2320,10 +2320,14 @@ static int parse_smacro_template(Token ***tpp, SMacro *tmpl) Token *t = *tn; Token *name; - while (t && t->type == TOK_WHITESPACE) { - tn = &t->next; - t = *tn; - } + /* + * DO NOT skip whitespace here, or we won't be able to distinguish: + * + * %define foo (a,b) ; no arguments, (a,b) is the expansion + * %define bar(a,b) ; two arguments, empty expansion + * + * This ambiguity was inherited from C. + */ if (!tok_is_(t, "(")) goto finish; -- cgit v1.2.1