Skip to content

Commit

Permalink
[GNU] Add line marker directive
Browse files Browse the repository at this point in the history
  • Loading branch information
rui314 committed Dec 7, 2020
1 parent c61c0d0 commit aaf20fb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions preprocess.c
Original file line number Diff line number Diff line change
Expand Up @@ -839,6 +839,11 @@ static Token *preprocess2(Token *tok) {
continue;
}

if (tok->kind == TK_PP_NUM) {
read_line_marker(&tok, tok);
continue;
}

if (equal(tok, "error"))
error_tok(tok, "error");

Expand Down
4 changes: 4 additions & 0 deletions test/line.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ int main() {
#line 1
ASSERT(2, __LINE__);

# 200 "xyz" 2 3
ASSERT(201, __LINE__);
ASSERT(0, strcmp(__FILE__, "xyz"));

printf("OK\n");
return 0;
}

0 comments on commit aaf20fb

Please sign in to comment.