From 328b826e8a43ed39f9eebb8493cc6abea2ddac1c Mon Sep 17 00:00:00 2001 From: Michael Matz Date: Sat, 15 Apr 2017 19:24:13 +0200 Subject: tccpp: Fix corner case of fnlike macro invocation Arg substitution leaves placeholder marker in the stream for empty arguments. Those need to be skipped when searching for a fnlike macro invocation in the replacement list itself. See testcase. --- tccpp.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'tccpp.c') diff --git a/tccpp.c b/tccpp.c index bdf2815..7e5cdcf 100644 --- a/tccpp.c +++ b/tccpp.c @@ -3023,7 +3023,7 @@ static int next_argstream(Sym **nested_list, int can_read_stream, TokenString *w if (macro_ptr) { p = macro_ptr, t = *p; if (ws_str) { - while (is_space(t) || TOK_LINEFEED == t) + while (is_space(t) || TOK_LINEFEED == t || TOK_PLCHLDR == t) tok_str_add(ws_str, t), t = *++p; } if (t == 0 && can_read_stream) { @@ -3152,7 +3152,9 @@ static int macro_subst_tok( } else { tok_str_free_str(ws_str.str); } - next_nomacro(); /* eat '(' */ + do { + next_nomacro(); /* eat '(' */ + } while (tok == TOK_PLCHLDR); /* argument macro */ args = NULL; -- cgit v1.3.1