diff options
author | Michael Forney <mforney@mforney.org> | 2021-10-28 00:55:59 -0700 |
---|---|---|
committer | Michael Forney <mforney@mforney.org> | 2021-12-06 13:51:58 -0800 |
commit | 673a92cead5dbc453a2234baffafb250cc1f41b6 (patch) | |
tree | 93e716ab03cc18407073d09ea66aa2d5c1857b3f | |
parent | 98719581d6b7c796c3c66bd1d103634e6e2c6eb5 (diff) |
decl: Simplify struct size calculation
-rw-r--r-- | decl.c | 5 |
1 files changed, 2 insertions, 3 deletions
@@ -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) |