mirror of
https://github.com/rui314/chibicc
synced 2025-02-20 15:43:58 +03:00
Skip nested #if in a skipped #if-clause
This commit is contained in:
parent
bf6ff928ad
commit
aa570f3086
@ -53,10 +53,16 @@ static Token *append(Token *tok1, Token *tok2) {
|
||||
}
|
||||
|
||||
// Skip until next `#endif`.
|
||||
// Nested `#if` and `#endif` are skipped.
|
||||
static Token *skip_cond_incl(Token *tok) {
|
||||
while (tok->kind != TK_EOF) {
|
||||
if (is_hash(tok) && equal(tok->next, "if")) {
|
||||
tok = skip_cond_incl(tok->next->next);
|
||||
tok = tok->next;
|
||||
continue;
|
||||
}
|
||||
if (is_hash(tok) && equal(tok->next, "endif"))
|
||||
return tok;
|
||||
break;
|
||||
tok = tok->next;
|
||||
}
|
||||
return tok;
|
||||
|
@ -17,6 +17,8 @@ int main() {
|
||||
#if 0
|
||||
#include "/no/such/file"
|
||||
assert(0, 1, "1");
|
||||
#if nested
|
||||
#endif
|
||||
#endif
|
||||
|
||||
int m = 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user