From b84e6efa47ef670dffaf05ee29e77ab52eee07b0 Mon Sep 17 00:00:00 2001 From: Michael Forney Date: Fri, 15 Feb 2019 12:43:23 -0800 Subject: Fix use of wrong align variable in structdecl --- decl.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'decl.c') diff --git a/decl.c b/decl.c index 5dee645..60f3970 100644 --- a/decl.c +++ b/decl.c @@ -630,22 +630,22 @@ structdecl(struct scope *s, struct type *t) struct member *m; int basealign = 0, align; - base = declspecs(s, NULL, NULL, &align); + base = declspecs(s, NULL, NULL, &basealign); if (!base) error(&tok.loc, "no type in struct member declaration"); if (tok.kind == TSEMICOLON) { if ((base->kind != TYPESTRUCT && base->kind != TYPEUNION) || base->structunion.tag) error(&tok.loc, "struct declaration must declare at least one member"); next(); - if (align < base->align) - align = base->align; - t->size = ALIGNUP(t->size, align); + if (basealign < base->align) + basealign = base->align; + t->size = ALIGNUP(t->size, basealign); arrayforeach (&base->structunion.members, m) m->offset += t->size; arrayaddbuf(&t->structunion.members, base->structunion.members.val, base->structunion.members.len); - t->size += ALIGNUP(base->size, align); - if (t->align < align) - t->align = align; + t->size += ALIGNUP(base->size, basealign); + if (t->align < basealign) + t->align = basealign; return; } for (;;) { -- cgit v1.2.3