Skip to content

Commit

Permalink
Expand macro only when preprocessor token is identifier
Browse files Browse the repository at this point in the history
In 'preprocess2' function, 'expand_macro' was called multiple times,
some of which were unnecessary. This change ensures that 'expand_macro'
is called only when the preprocessor token is an identifier.
  • Loading branch information
jserv committed Nov 23, 2024
1 parent d67ae4b commit d80d590
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion preprocess.c
Original file line number Diff line number Diff line change
Expand Up @@ -1077,7 +1077,7 @@ static Token *preprocess2(Token *tok) {

for (; tok->kind != TK_EOF; pop_macro_lock(tok)) {
// If it is a macro, expand it.
if (expand_macro(&tok, tok))
if (tok->kind == TK_IDENT && expand_macro(&tok, tok))
continue;

if (is_hash(tok) && !locked_macros) {
Expand Down

0 comments on commit d80d590

Please sign in to comment.