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 673ddb9e58883da5a8840fa7f5b16a439b3f5dd7
parent 9150901e4ebde2273bf266d608a7a05228e1d0df
Author: Michael Forney <mforney@mforney.org>
Date:   Wed, 20 Feb 2019 18:20:40 -0800

Fix emittype for unions

Thanks to Andrew Chambers for the bug report.

Diffstat:
Mqbe.c | 4+++-
Atests/union-passing.c | 2++
Atests/union-passing.qbe | 7+++++++
3 files changed, 12 insertions(+), 1 deletion(-)

diff --git 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("}"); } diff --git a/tests/union-passing.c b/tests/union-passing.c @@ -0,0 +1,2 @@ +void f(union {int x;} u) { +} diff --git a/tests/union-passing.qbe b/tests/union-passing.qbe @@ -0,0 +1,7 @@ +type :.1 = { w, } +export +function $f(:.1 %.1) { +@start.1 +@body.2 + ret +}