aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Forney <mforney@mforney.org>2021-10-28 00:55:59 -0700
committerMichael Forney <mforney@mforney.org>2021-12-06 13:51:58 -0800
commit673a92cead5dbc453a2234baffafb250cc1f41b6 (patch)
tree93e716ab03cc18407073d09ea66aa2d5c1857b3f
parent98719581d6b7c796c3c66bd1d103634e6e2c6eb5 (diff)
decl: Simplify struct size calculation
-rw-r--r--decl.c5
1 files 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)