[PATCH 06/13] flex-array: warn on flexible arrays in unions

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

 



Flexible array members are not allowed in unions.
So, warn if one is present.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx>
---
 symbol.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/symbol.c b/symbol.c
index 6633e89de4a9..e578b1a840a3 100644
--- a/symbol.c
+++ b/symbol.c
@@ -95,6 +95,9 @@ struct struct_union_info {
  */
 static void lay_out_union(struct symbol *sym, struct struct_union_info *info)
 {
+	if (sym->bit_size < 0 && is_array_type(sym))
+		sparse_error(sym->pos, "flexible array member '%s' in a union", show_ident(sym->ident));
+
 	if (sym->bit_size > info->bit_size)
 		info->bit_size = sym->bit_size;
 
-- 
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