diff options
author | Michael Forney <mforney@mforney.org> | 2019-02-15 12:43:23 -0800 |
---|---|---|
committer | Michael Forney <mforney@mforney.org> | 2019-02-15 12:43:23 -0800 |
commit | b84e6efa47ef670dffaf05ee29e77ab52eee07b0 (patch) | |
tree | 154b7f8518a91177a0958e5dbc9af8fce6a5bbe6 /decl.c | |
parent | 35998a93f9a59a34477890637fda75982d9a5e1c (diff) |
Fix use of wrong align variable in structdecl
Diffstat (limited to 'decl.c')
-rw-r--r-- | decl.c | 14 |
1 files changed, 7 insertions, 7 deletions
@@ -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 (;;) { |