mirror of
https://github.com/frida/tinycc
synced 2024-12-26 15:06:58 +03:00
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:
parent
15f4ac2b1a
commit
4c0d70ab07
19
tccpp.c
19
tccpp.c
@ -2697,10 +2697,25 @@ static int macro_subst_tok(TokenString *tok_str,
|
|||||||
goto redo;
|
goto redo;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* XXX: incorrect with comments */
|
|
||||||
ch = file->buf_ptr[0];
|
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();
|
cinp();
|
||||||
|
}
|
||||||
t = ch;
|
t = ch;
|
||||||
}
|
}
|
||||||
if (t != '(') /* no macro subst */
|
if (t != '(') /* no macro subst */
|
||||||
|
@ -288,6 +288,10 @@ comment
|
|||||||
/* test function macro substitution when the function name is
|
/* test function macro substitution when the function name is
|
||||||
substituted */
|
substituted */
|
||||||
TEST2();
|
TEST2();
|
||||||
|
|
||||||
|
/* And again when the name and parenthes are separated by a
|
||||||
|
comment. */
|
||||||
|
TEST2 /* the comment */ ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user