aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2020-07-11 15:45:15 +0200
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2020-07-14 01:27:55 +0200
commit14b55d27ee7d577be66c60a457f0e80a28ef274d (patch)
tree8f495b4acdb25f4c0139503cb3492f9aed17936d
parent584bf4cd77d422d7f057c9ed167f824955a3c311 (diff)
downloadsparse-14b55d27ee7d577be66c60a457f0e80a28ef274d.tar.gz
warn on empty initializations
Currently sparse accepts an empty initialization like: int a = ; Make this an error. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-rw-r--r--parse.c5
-rw-r--r--validation/empty-initializer.c1
2 files changed, 4 insertions, 2 deletions
diff --git a/parse.c b/parse.c
index a9222e7c..d0a41b14 100644
--- a/parse.c
+++ b/parse.c
@@ -3117,7 +3117,10 @@ struct token *external_declaration(struct token *token, struct symbol_list **lis
for (;;) {
if (!is_typedef && match_op(token, '=')) {
- token = initializer(&decl->initializer, token->next);
+ struct token *next = token->next;
+ token = initializer(&decl->initializer, next);
+ if (token == next)
+ sparse_error(token->pos, "expression expected before '%s'", show_token(token));
}
if (!is_typedef) {
if (validate_decl)
diff --git a/validation/empty-initializer.c b/validation/empty-initializer.c
index 0ca763f6..95067999 100644
--- a/validation/empty-initializer.c
+++ b/validation/empty-initializer.c
@@ -2,7 +2,6 @@ static int i = ; // KO
/*
* check-name: empty-initializer
- * check-known-to-fail
*
* check-error-start
empty-initializer.c:1:16: error: expression expected before ';'