diff options
| author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2020-09-19 11:02:02 +0200 |
|---|---|---|
| committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2020-10-01 00:44:53 +0200 |
| commit | e5b7d1ecb8425fda8674b1c0b73a118e4aa16560 (patch) | |
| tree | 4ccb8cbec78b76d897e4d3ffc334117e7875b5d2 | |
| parent | 644f20bb0e0aa76480f6c4c2d3d38001dd289626 (diff) | |
| download | sparse-dev-e5b7d1ecb8425fda8674b1c0b73a118e4aa16560.tar.gz | |
flex-array: factor out common part of lay_out_{struct,union}()
This is a preparatory step for later patches.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
| -rw-r--r-- | symbol.c | 24 |
1 files changed, 8 insertions, 16 deletions
@@ -94,14 +94,6 @@ struct struct_union_info { */ static void lay_out_union(struct symbol *sym, struct struct_union_info *info) { - examine_symbol_type(sym); - - // Unnamed bitfields do not affect alignment. - if (sym->ident || !is_bitfield_type(sym)) { - if (sym->ctype.alignment > info->max_align) - info->max_align = sym->ctype.alignment; - } - if (sym->bit_size > info->bit_size) info->bit_size = sym->bit_size; @@ -125,14 +117,6 @@ static void lay_out_struct(struct symbol *sym, struct struct_union_info *info) unsigned long bit_size, align_bit_mask; int base_size; - examine_symbol_type(sym); - - // Unnamed bitfields do not affect alignment. - if (sym->ident || !is_bitfield_type(sym)) { - if (sym->ctype.alignment > info->max_align) - info->max_align = sym->ctype.alignment; - } - bit_size = info->bit_size; base_size = sym->bit_size; @@ -196,6 +180,14 @@ 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; } + examine_symbol_type(member); + + if (member->ctype.alignment > info.max_align) { + // Unnamed bitfields do not affect alignment. + if (member->ident || !is_bitfield_type(member)) + info.max_align = member->ctype.alignment; + } + fn(member, &info); } END_FOR_EACH_PTR(member); |
