diff options
Diffstat (limited to 'qbe.c')
-rw-r--r-- | qbe.c | 11 |
1 files changed, 3 insertions, 8 deletions
@@ -422,13 +422,6 @@ funcjnz(struct function *f, struct value *v, struct value *l1, struct value *l2) void funcret(struct function *f, struct value *v) { - struct declaration *d; - - if (!v && f->type->base->kind != TYPEVOID) { - d = mkdecl(DECLOBJECT, f->type->base, LINKNONE); - funcinit(f, d, NULL); - v = funcload(f, d->type, d->value); - } funcinst(f, IRET, NULL, v); f->end->terminated = true; } @@ -891,6 +884,8 @@ funcinit(struct function *func, struct declaration *d, struct initializer *init) size_t i; funcalloc(func, d); + if (!init) + return; for (; init; init = init->next) { zero(func, d->value, d->type->align, offset, init->start); if (init->expr->kind == EXPRSTRING) { @@ -1101,7 +1096,7 @@ emitfunc(struct function *f, bool global) size_t n; if (!f->end->terminated) - funcret(f, NULL); + funcret(f, strcmp(f->name, "main") == 0 ? mkintconst(&i32, 0) : NULL); if (global) puts("export"); fputs("function ", stdout); |