aboutsummaryrefslogtreecommitdiff
path: root/decl.c
diff options
context:
space:
mode:
authorMichael Forney <mforney@mforney.org>2019-04-27 20:33:56 -0700
committerMichael Forney <mforney@mforney.org>2019-04-27 20:38:42 -0700
commit2b34742bf0dbabbdb7335838902323df66974b39 (patch)
tree021c5487c20d5bbae5ae12c4ddddf81aad135cc6 /decl.c
parent1ef0706e1f2e97d0872eb801169de5023c3c8b7f (diff)
Unnamed bit-fields don't contribute to size or alignment of unions, or size of structs
Diffstat (limited to 'decl.c')
-rw-r--r--decl.c12
1 files changed, 5 insertions, 7 deletions
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;
}