From 2b34742bf0dbabbdb7335838902323df66974b39 Mon Sep 17 00:00:00 2001 From: Michael Forney Date: Sat, 27 Apr 2019 20:33:56 -0700 Subject: Unnamed bit-fields don't contribute to size or alignment of unions, or size of structs --- decl.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'decl.c') diff --git a/decl.c b/decl.c index 35ba57a..b771a04 100644 --- a/decl.c +++ b/decl.c @@ -714,17 +714,15 @@ addmember(struct structbuilder *b, struct qualtype mt, char *name, int align, ui } t->size += (width - b->bits + 7) / 8; b->bits = (b->bits - width) % 8; - } else { - if (m) { - m->offset = 0; - m->bits.before = 0; - m->bits.after = mt.type->size * 8 - width; - } + } else if (m) { + m->offset = 0; + m->bits.before = 0; + m->bits.after = mt.type->size * 8 - width; if (t->size < mt.type->size) t->size = mt.type->size; } } - if (t->align < align) + if (m && t->align < align) t->align = align; } -- cgit v1.2.3