diff options
author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2020-10-26 05:38:58 +0100 |
---|---|---|
committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2020-10-26 05:52:42 +0100 |
commit | 0d6bb7e115657c42e43861536073a345a0c3945b (patch) | |
tree | 8d5185cf05758fd5c5d6593b8f951eb12b80322d | |
parent | c09e8239027fea6999bb3b64c157fc2133769444 (diff) | |
download | sparse-0d6bb7e115657c42e43861536073a345a0c3945b.tar.gz |
handle more graciously labels with no statement
In C a label must precede a statement. A null statement is OK
but a closing braces is not.
So, catch this situation, emit a warning and continue as if a
null statement was there.
This occurs currently on v5.10-rc1 because of some ifdefery.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-rw-r--r-- | parse.c | 5 |
1 files changed, 5 insertions, 0 deletions
@@ -2468,6 +2468,11 @@ static struct token *statement(struct token *token, struct statement **tree) warn_label_usage(stmt->pos, s->label_pos, s->ident); } s->stmt = stmt; + if (match_op(token, '}')) { + warning(token->pos, "statement expected after label"); + stmt->label_statement = alloc_statement(token->pos, STMT_NONE); + return token; + } return statement(token, &stmt->label_statement); } } |