summaryrefslogtreecommitdiff
path: root/6/blob.c
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2015-12-28 17:30:52 -0800
committerOri Bernstein <ori@eigenstate.org>2015-12-28 23:41:42 -0800
commite11e5f143419b049f2c93a4b361a668b57a77fc0 (patch)
treebf73defd1b9acd449efd7ffe9e1ecdab4a951522 /6/blob.c
parent07f5aa5bbf9445c1ff188a6f75a6fa162119cc35 (diff)
downloadmc-e11e5f143419b049f2c93a4b361a668b57a77fc0.tar.gz
Fix union alignment.
Diffstat (limited to '6/blob.c')
-rw-r--r--6/blob.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/6/blob.c b/6/blob.c
index 0be2af2..e101571 100644
--- a/6/blob.c
+++ b/6/blob.c
@@ -233,14 +233,17 @@ static size_t blobstruct(Blob *seq, Htab *globls, Htab *strtab, Node *n)
static size_t blobucon(Blob *seq, Htab *globls, Htab *strtab, Node *n)
{
- size_t sz;
+ size_t sz, pad;
Ucon *uc;
sz = 4;
uc = finducon(exprtype(n), n->expr.args[0]);
b(seq, mkblobi(Bti32, uc->id));
- if (n->expr.nargs > 1)
+ if (n->expr.nargs > 1) {
+ pad = tyalign(exprtype(n->expr.args[1])) - sz;
+ sz += blobpad(seq, pad);
sz += blobrec(seq, globls, strtab, n->expr.args[1]);
+ }
sz += blobpad(seq, size(n) - sz);
return sz;
}