cproc

Unnamed repository; edit this file 'description' to name the repository.
git clone git://git.nihaljere.xyz/cproc
Log | Files | Refs | Submodules | README | LICENSE

commit b84e6efa47ef670dffaf05ee29e77ab52eee07b0
parent 35998a93f9a59a34477890637fda75982d9a5e1c
Author: Michael Forney <mforney@mforney.org>
Date:   Fri, 15 Feb 2019 12:43:23 -0800

Fix use of wrong align variable in structdecl

Diffstat:
Mdecl.c | 14+++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)

diff --git 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 (;;) {