aboutsummaryrefslogtreecommitdiff
path: root/qbe.c
diff options
context:
space:
mode:
authorMichael Forney <mforney@mforney.org>2019-02-20 18:20:40 -0800
committerMichael Forney <mforney@mforney.org>2019-02-20 18:24:54 -0800
commit673ddb9e58883da5a8840fa7f5b16a439b3f5dd7 (patch)
treef6ab6d5d7738ba0350b0e0e4f2230a04da10a53f /qbe.c
parent9150901e4ebde2273bf266d608a7a05228e1d0df (diff)
Fix emittype for unions
Thanks to Andrew Chambers for the bug report.
Diffstat (limited to 'qbe.c')
-rw-r--r--qbe.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/qbe.c b/qbe.c
index d3d14f2..75be4c5 100644
--- a/qbe.c
+++ b/qbe.c
@@ -1007,13 +1007,15 @@ emittype(struct type *t)
fputs("type :", stdout);
emitname(&t->repr->abi);
fputs(" = { ", stdout);
- for (m = t->structunion.members; m && t->kind == TYPESTRUCT; m = m->next) {
+ for (m = t->structunion.members; m; m = m->next) {
for (i = 1, sub = m->type; sub->kind == TYPEARRAY; sub = sub->base)
i *= sub->array.length;
emitrepr(sub->repr, true, true);
if (i > 1)
printf(" %" PRIu64, i);
fputs(", ", stdout);
+ if (t->kind == TYPEUNION)
+ break;
}
puts("}");
}