stage2: add retvoid support to CBE

This commit is contained in:
Andrew Kelley
2020-07-13 00:28:11 -07:00
parent 25b1c00c72
commit 08154c0deb
4 changed files with 14 additions and 11 deletions

View File

@@ -1210,8 +1210,9 @@ fn astGenAndAnalyzeDecl(self: *Module, decl: *Decl) !bool {
try self.astGenBlock(&gen_scope.base, body_block);
const last_inst = gen_scope.instructions.items[gen_scope.instructions.items.len - 1];
if (!last_inst.tag.isNoReturn()) {
if (!fn_type.fnReturnType().isNoReturn() and (gen_scope.instructions.items.len == 0 or
!gen_scope.instructions.items[gen_scope.instructions.items.len - 1].tag.isNoReturn()))
{
const src = tree.token_locs[body_block.rbrace].start;
_ = try self.addZIRInst(&gen_scope.base, src, zir.Inst.ReturnVoid, .{}, .{});
}