diff options
| -rw-r--r-- | lib.c | 9 | ||||
| -rw-r--r-- | token.h | 1 |
2 files changed, 9 insertions, 1 deletions
@@ -70,7 +70,7 @@ struct token *skip_to(struct token *token, int op) return token; } -static struct token bad_token; +static struct token bad_token = { .pos.type = TOKEN_BAD }; struct token *expect(struct token *token, int op, const char *where) { if (!match_op(token, op)) { @@ -123,6 +123,10 @@ static void do_warn(const char *type, struct position pos, const char * fmt, va_ static char buffer[512]; const char *name; + /* Shut up warnings if position is bad_token.pos */ + if (pos.type == TOKEN_BAD) + return; + vsprintf(buffer, fmt, args); name = stream_name(pos.stream); @@ -150,6 +154,9 @@ static void do_error(struct position pos, const char * fmt, va_list args) static int errors = 0; die_if_error = 1; show_info = 1; + /* Shut up warnings if position is bad_token.pos */ + if (pos.type == TOKEN_BAD) + return; /* Shut up warnings after an error */ has_error |= ERROR_CURR_PHASE; if (errors > 100) { @@ -79,6 +79,7 @@ struct ident { enum token_type { TOKEN_EOF, + TOKEN_BAD, TOKEN_ERROR, TOKEN_IDENT, TOKEN_ZERO_IDENT, |
