diff options
author | Michael Forney <mforney@mforney.org> | 2019-02-15 20:16:38 -0800 |
---|---|---|
committer | Michael Forney <mforney@mforney.org> | 2019-02-15 20:16:38 -0800 |
commit | f4a3a6504b1cf2bc28a2ad87ac5befcda6b78050 (patch) | |
tree | d2b40d9765947f7a3c267cb123e423f7c4c85900 /qbe.c | |
parent | 2c7f9d3a0131ca4f2060d05edfa2a67a190cd11f (diff) |
Make sure that aggregates and pointers to aggregates are passed/return correctly
Diffstat (limited to 'qbe.c')
-rw-r--r-- | qbe.c | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -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); |