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 f4a3a6504b1cf2bc28a2ad87ac5befcda6b78050
parent 2c7f9d3a0131ca4f2060d05edfa2a67a190cd11f
Author: Michael Forney <mforney@mforney.org>
Date:   Fri, 15 Feb 2019 20:16:38 -0800

Make sure that aggregates and pointers to aggregates are passed/return correctly

Diffstat:
Mqbe.c | 10++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/qbe.c b/qbe.c @@ -290,6 +290,7 @@ funcstore(struct function *f, struct type *t, struct value *addr, struct value * static struct value * funcload(struct function *f, struct type *t, struct value *addr) { + struct value *v; enum instructionkind op; enum typequalifier tq; @@ -311,7 +312,10 @@ funcload(struct function *f, struct type *t, struct value *addr) case TYPESTRUCT: case TYPEUNION: case TYPEARRAY: - return addr; + v = xmalloc(sizeof(*v)); + *v = *addr; + v->repr = t->repr; + return v; default: fatal("unimplemented load %d", t->kind); } @@ -356,7 +360,9 @@ mkfunc(char *name, struct type *t, struct scope *s) p->value = xmalloc(sizeof(*p->value)); functemp(f, p->value, p->type->repr); if (p->type->repr->abi.id) { - d->value = p->value; + d->value = xmalloc(sizeof(*d->value)); + *d->value = *p->value; + d->value->repr = &iptr; } else { funcinit(f, d, NULL); funcstore(f, typeunqual(p->type, NULL), d->value, p->value);