summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2020-09-19 11:10:14 +0200
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2020-10-01 00:44:53 +0200
commitaa64a1b91cfb6641a759def918a15b3089e314f7 (patch)
tree9205b2fe9c211055d0a6abceed974390f6f408b6
parentb6d76fee64b9b2bf36760609d8f2030f71f759fe (diff)
downloadsparse-aa64a1b91cfb6641a759def918a15b3089e314f7.tar.gz
flex-array: warn if flexible array is not last
Flexible array members must be the last in a structure. Warn if it is not the case. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-rw-r--r--symbol.c2
-rw-r--r--validation/flex-array-error.c1
2 files changed, 2 insertions, 1 deletions
diff --git a/symbol.c b/symbol.c
index e578b1a8..b4c5e471 100644
--- a/symbol.c
+++ b/symbol.c
@@ -186,6 +186,8 @@ static struct symbol * examine_struct_union_type(struct symbol *sym, int advance
sparse_error(member->pos, "member '%s' has __auto_type", show_ident(member->ident));
member->ctype.base_type = &incomplete_ctype;
}
+ if (info.flex_array)
+ sparse_error(info.flex_array->pos, "flexible array member '%s' is not last", show_ident(info.flex_array->ident));
examine_symbol_type(member);
if (member->ctype.alignment > info.max_align) {
diff --git a/validation/flex-array-error.c b/validation/flex-array-error.c
index 89601e42..2b7e6953 100644
--- a/validation/flex-array-error.c
+++ b/validation/flex-array-error.c
@@ -18,7 +18,6 @@ static int foo(struct s *s, union u *u)
/*
* check-name: flex-array-error
- * check-known-to-fail
*
* check-error-start
flex-array-error.c:3:14: error: flexible array member 'f' is not last