aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2020-10-26 05:38:58 +0100
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2020-10-26 05:52:42 +0100
commit0d6bb7e115657c42e43861536073a345a0c3945b (patch)
tree8d5185cf05758fd5c5d6593b8f951eb12b80322d
parentc09e8239027fea6999bb3b64c157fc2133769444 (diff)
downloadsparse-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.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/parse.c b/parse.c
index 31ecef0f..b6090d38 100644
--- a/parse.c
+++ b/parse.c
@@ -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);
}
}