mirror of
https://github.com/mirror/tinycc.git
synced 2025-04-13 13:10:50 +08:00
tccpp.c: fix ##-in-macros logic
The old code had an inverted condition, so #define a(b)## b would be accepted while #define a(b,c) b ## ## c would be rejected with the confusing error message "'##' invalid at start of macro".
This commit is contained in:
parent
a6b94eff79
commit
3a922ad2ba
4
tccpp.c
4
tccpp.c
@ -1296,7 +1296,7 @@ ST_FUNC void parse_define(void)
|
||||
ptok = 0;
|
||||
macro_list_start = 1;
|
||||
while (tok != TOK_LINEFEED && tok != TOK_EOF) {
|
||||
if (!macro_list_start && spc == 2 && tok == TOK_TWOSHARPS)
|
||||
if (macro_list_start && spc == 2 && tok == TOK_TWOSHARPS)
|
||||
tcc_error("'##' invalid at start of macro");
|
||||
ptok = tok;
|
||||
/* remove spaces around ## and after '#' */
|
||||
@ -1310,9 +1310,9 @@ ST_FUNC void parse_define(void)
|
||||
goto skip;
|
||||
}
|
||||
tok_str_add2(&str, tok, &tokc);
|
||||
macro_list_start = 0;
|
||||
skip:
|
||||
next_nomacro_spc();
|
||||
macro_list_start = 0;
|
||||
}
|
||||
if (ptok == TOK_TWOSHARPS)
|
||||
tcc_error("'##' invalid at end of macro");
|
||||
|
Loading…
Reference in New Issue
Block a user