| ... | ... | @@ -7170,23 +7170,24 @@ fn analyzeCall( |
| 7170 | 7170 | try sema.ensureResultUsed(block, sema.typeOf(func_inst), call_src); |
| 7171 | 7171 | } |
| 7172 | 7172 | return sema.handleTailCall(block, call_src, func_ty, func_inst); |
| 7173 | | } else if (block.wantSafety() and func_ty_info.return_type == .noreturn_type) { |
| 7173 | } |
| 7174 | if (block.wantSafety() and func_ty_info.return_type == .noreturn_type) skip_safety: { |
| 7174 | 7175 | // Function pointers and extern functions aren't guaranteed to |
| 7175 | 7176 | // actually be noreturn so we add a safety check for them. |
| 7176 | | check: { |
| 7177 | | const func_val = (try sema.resolveMaybeUndefVal(func)) orelse break :check; |
| 7177 | if (try sema.resolveMaybeUndefVal(func)) |func_val| { |
| 7178 | 7178 | switch (mod.intern_pool.indexToKey(func_val.toIntern())) { |
| 7179 | | .func, .extern_func, .ptr => { |
| 7180 | | _ = try block.addNoOp(.unreach); |
| 7181 | | return Air.Inst.Ref.unreachable_value; |
| 7179 | .func => break :skip_safety, |
| 7180 | .ptr => |ptr| switch (ptr.addr) { |
| 7181 | .decl => |decl| if (!mod.declPtr(decl).isExtern(mod)) break :skip_safety, |
| 7182 | else => {}, |
| 7182 | 7183 | }, |
| 7183 | | else => break :check, |
| 7184 | else => {}, |
| 7184 | 7185 | } |
| 7185 | 7186 | } |
| 7186 | | |
| 7187 | 7187 | try sema.safetyPanic(block, .noreturn_returned); |
| 7188 | 7188 | return Air.Inst.Ref.unreachable_value; |
| 7189 | | } else if (func_ty_info.return_type == .noreturn_type) { |
| 7189 | } |
| 7190 | if (func_ty_info.return_type == .noreturn_type) { |
| 7190 | 7191 | _ = try block.addNoOp(.unreach); |
| 7191 | 7192 | return Air.Inst.Ref.unreachable_value; |
| 7192 | 7193 | } |