From 673a92cead5dbc453a2234baffafb250cc1f41b6 Mon Sep 17 00:00:00 2001 From: Michael Forney Date: Thu, 28 Oct 2021 00:55:59 -0700 Subject: decl: Simplify struct size calculation --- decl.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/decl.c b/decl.c index 5f1d778..53aca7f 100644 --- a/decl.c +++ b/decl.c @@ -698,10 +698,9 @@ addmember(struct structbuilder *b, struct qualtype mt, char *name, int align, un error(&tok.loc, "specified alignment of struct member is less strict than is required by type"); align = mt.type->align; } - t->size = ALIGNUP(t->size, align); if (t->kind == TYPESTRUCT) { - m->offset = t->size; - t->size += mt.type->size; + m->offset = ALIGNUP(t->size, align); + t->size = m->offset + mt.type->size; } else { m->offset = 0; if (t->size < mt.type->size) -- cgit v1.2.3