From 9c5b852f9bb47e25c878cbccdaa175517ae48fc6 Mon Sep 17 00:00:00 2001 From: Matthew Borkowski Date: Sat, 23 Oct 2021 21:52:21 -0400 Subject: astgen.zig: emit ZIR for callconv before return type in fnDecl and fnProtoExpr --- test/behavior/fn_stage1.zig | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'test') diff --git a/test/behavior/fn_stage1.zig b/test/behavior/fn_stage1.zig index 06c5d8fdb2..9368b39a46 100644 --- a/test/behavior/fn_stage1.zig +++ b/test/behavior/fn_stage1.zig @@ -204,3 +204,19 @@ test "function with inferred error set but returning no error" { const return_ty = @typeInfo(@TypeOf(S.foo)).Fn.return_type.?; try expectEqual(0, @typeInfo(@typeInfo(return_ty).ErrorUnion.error_set).ErrorSet.?.len); } + +const nComplexCallconv = 100; +fn fComplexCallconvRet(x: u32) callconv(blk: { + const s: struct { n: u32 } = .{ .n = nComplexCallconv }; + break :blk switch (s.n) { + 0 => .C, + 1 => .Inline, + else => .Unspecified, + }; +}) struct { x: u32 } { + return .{ .x = x * x }; +} + +test "function with complex callconv and return type expressions" { + try expect(fComplexCallconvRet(3).x == 9); +} -- cgit v1.2.3