aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorVeikka Tuominen <git@vexu.eu>2022-08-30 17:13:35 +0300
committerAndrew Kelley <andrew@ziglang.org>2022-08-30 12:22:07 -0700
commit65d37239682b6418b6dd25f07187ae99088e67f0 (patch)
treeb8ea48551a149e889247f07a09353eb452ff4e1f /src
parentc558de6655e2e9b72c5733b2d477ff18520d1c6b (diff)
downloadzig-65d37239682b6418b6dd25f07187ae99088e67f0.tar.gz
zig-65d37239682b6418b6dd25f07187ae99088e67f0.zip
Sema: check that target supports tail calls
Diffstat (limited to 'src')
-rw-r--r--src/Sema.zig4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/Sema.zig b/src/Sema.zig
index 74f19e5b93..8cde9d7e12 100644
--- a/src/Sema.zig
+++ b/src/Sema.zig
@@ -6160,6 +6160,10 @@ fn analyzeCall(
}
fn handleTailCall(sema: *Sema, block: *Block, call_src: LazySrcLoc, func_ty: Type, result: Air.Inst.Ref) !Air.Inst.Ref {
+ const target = sema.mod.getTarget();
+ if (!target.supportsTailCall()) {
+ return sema.fail(block, call_src, "unable to perform tail call: target does not support tail calls", .{});
+ }
const func_decl = sema.mod.declPtr(sema.owner_func.?.owner_decl);
if (!func_ty.eql(func_decl.ty, sema.mod)) {
return sema.fail(block, call_src, "unable to perform tail call: type of function being called '{}' does not match type of calling function '{}'", .{