[PATCH 07/13] flex-array: warn if flexible array is not last

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
---
 symbol.c                      | 2 ++
 validation/flex-array-error.c | 1 -
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/symbol.c b/symbol.c
index e578b1a840a3..b4c5e471372b 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 89601e42daf6..2b7e6953050c 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
-- 
2.28.0




[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux