aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/preprocess.c11
-rw-r--r--src/token.c2
-rw-r--r--src/token.h1
3 files changed, 14 insertions, 0 deletions
diff --git a/src/preprocess.c b/src/preprocess.c
index c96c194..2a53059 100644
--- a/src/preprocess.c
+++ b/src/preprocess.c
@@ -176,6 +176,10 @@ static TokenKind pplexer_tokenize_pp_directive(PpLexer* ppl) {
break;
infile_next_char(ppl->src);
}
+ // '#' new-line
+ if (c == '\n') {
+ return TokenKind_pp_directive_nop;
+ }
SourceLocation pp_directive_name_start_loc = ppl->src->loc;
@@ -935,6 +939,11 @@ static void process_pragma_directive(Preprocessor* pp, int directive_token_pos)
unimplemented();
}
+static void process_nop_directive(Preprocessor* pp, int directive_token_pos) {
+ next_pp_token(pp);
+ remove_directive_tokens(pp, directive_token_pos, pp->pos);
+}
+
// ws ::= many0(<Whitespace>)
// macro-arguments ::= '(' <ws> opt(<any-token> <ws> many0(',' <ws> <any-token> <ws>)) ')'
static MacroArgArray* pp_parse_macro_arguments(Preprocessor* pp) {
@@ -1047,6 +1056,8 @@ static void process_pp_directive(Preprocessor* pp) {
process_error_directive(pp, first_token_pos);
} else if (tok->kind == TokenKind_pp_directive_pragma) {
process_pragma_directive(pp, first_token_pos);
+ } else if (tok->kind == TokenKind_pp_directive_nop) {
+ process_nop_directive(pp, first_token_pos);
} else if (tok->kind == TokenKind_ident) {
BOOL expanded = expand_macro(pp);
if (expanded) {
diff --git a/src/token.c b/src/token.c
index 40463cd..71eabaf 100644
--- a/src/token.c
+++ b/src/token.c
@@ -44,6 +44,8 @@ const char* token_kind_stringify(TokenKind k) {
return "#include";
else if (k == TokenKind_pp_directive_line)
return "#line";
+ else if (k == TokenKind_pp_directive_nop)
+ return "#";
else if (k == TokenKind_pp_directive_pragma)
return "#pragma";
else if (k == TokenKind_pp_directive_undef)
diff --git a/src/token.h b/src/token.h
index 6f5fb2a..034b3b3 100644
--- a/src/token.h
+++ b/src/token.h
@@ -27,6 +27,7 @@ enum TokenKind {
TokenKind_pp_directive_ifndef,
TokenKind_pp_directive_include,
TokenKind_pp_directive_line,
+ TokenKind_pp_directive_nop,
TokenKind_pp_directive_pragma,
TokenKind_pp_directive_undef,
TokenKind_pp_directive_warning,