Fix parsing function macro invocations

If a function macro name is separated from the parentheses in
an macro invocation the substitution doesn't take place.
Fix this by handling comments.
This commit is contained in:
Michael Matz 2012-04-16 00:21:40 +02:00
parent 15f4ac2b1a
commit 4c0d70ab07
2 changed files with 22 additions and 3 deletions

19
tccpp.c
View File

@ -2697,10 +2697,25 @@ static int macro_subst_tok(TokenString *tok_str,
goto redo;
}
} else {
/* XXX: incorrect with comments */
ch = file->buf_ptr[0];
while (is_space(ch) || ch == '\n')
while (is_space(ch) || ch == '\n' || ch == '/')
{
if (ch == '/')
{
int c;
uint8_t *p = file->buf_ptr;
PEEKC(c, p);
if (c == '*') {
p = parse_comment(p);
file->buf_ptr = p - 1;
} else if (c == '/') {
p = parse_line_comment(p);
file->buf_ptr = p - 1;
} else
break;
}
cinp();
}
t = ch;
}
if (t != '(') /* no macro subst */

View File

@ -288,6 +288,10 @@ comment
/* test function macro substitution when the function name is
substituted */
TEST2();
/* And again when the name and parenthes are separated by a
comment. */
TEST2 /* the comment */ ();
}