Skip to content

Commit

Permalink
Fix bug in reading #line filename inside #if block
Browse files Browse the repository at this point in the history
  • Loading branch information
sgraham committed May 6, 2024
1 parent cc94458 commit e02820c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/preprocess.c
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,8 @@ static Token* include_file(Token* tok, char* path, Token* filename_tok) {
// Read #line arguments
static void read_line_marker(Token** rest, Token* tok) {
Token* start = tok;
tok = preprocess(copy_line(rest, tok));
tok = preprocess2(copy_line(rest, tok));
convert_pp_tokens(tok);

if (tok->kind != TK_NUM || tok->ty->kind != TY_INT)
error_tok(tok, "invalid line marker");
Expand Down
4 changes: 4 additions & 0 deletions test/line_directive_bug.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#if 1
#line 1 "file"
#endif
int main() {}

0 comments on commit e02820c

Please sign in to comment.