diff options
author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2020-09-24 21:52:15 +0200 |
---|---|---|
committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2020-10-01 00:44:53 +0200 |
commit | bf3144077b3d4284d9ba3cbb62e22e23fb1d0a51 (patch) | |
tree | 82ea48ca8a8fc6481184cf238777fcc1b93ae295 | |
parent | aa64a1b91cfb6641a759def918a15b3089e314f7 (diff) | |
download | sparse-bf3144077b3d4284d9ba3cbb62e22e23fb1d0a51.tar.gz |
flex-array: identify structures with a flexible array member
Structures containing a flexible array must not be nested.
So, as a preparatory step, detect structures or union containing
a flexible array, possibly recursively and mark the corresponding
type with a dedicated flag.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-rw-r--r-- | symbol.c | 6 | ||||
-rw-r--r-- | symbol.h | 1 |
2 files changed, 7 insertions, 0 deletions
@@ -87,6 +87,7 @@ struct struct_union_info { unsigned long max_align; unsigned long bit_size; int align_size; + char has_flex_array; struct symbol *flex_array; }; @@ -206,6 +207,11 @@ static struct symbol * examine_struct_union_type(struct symbol *sym, int advance bit_align = bytes_to_bits(sym->ctype.alignment)-1; bit_size = (bit_size + bit_align) & ~bit_align; } + if (info.flex_array) { + info.has_flex_array = 1; + } + if (info.has_flex_array) + sym->has_flex_array = 1; sym->bit_size = bit_size; return sym; } @@ -185,6 +185,7 @@ struct symbol { examined:1, expanding:1, evaluated:1, + has_flex_array:1, string:1, designated_init:1, forced_arg:1, |