authorgravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2025-02-09 10:12:15-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-02-10 17:20:52-08:00
log74fbcd22e6ebd12c227e1ba293d71c692f0edb8b
tree817f37d1b1a250efda6dcf595d5ebec61c53f52f
parenteb7963e4c7a0731c1ade884b9c6ae0d818bccafe

cbe: fix crash rendering argument names in lazy functions

Closes #19905

2 files changed, 23 insertions(+), 19 deletions(-)

src/codegen/c.zig+1-1
......@@ -2855,7 +2855,7 @@ pub fn genLazyFn(o: *Object, lazy_ctype_pool: *const CType.Pool, lazy_fn: LazyFn
28552855 try w.writeByte('(');
28562856 for (0..fn_info.param_ctypes.len) |arg| {
28572857 if (arg > 0) try w.writeAll(", ");
2858 try o.dg.writeCValue(w, .{ .arg = arg });
2858 try w.print("a{d}", .{arg});
28592859 }
28602860 try w.writeAll(");\n}\n");
28612861 },
test/behavior/call.zig+22-18
......@@ -21,37 +21,41 @@ test "super basic invocations" {
2121
2222test "basic invocations" {
2323 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
24 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
2524 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
2625 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
2726 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
2827 if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
2928
29 if (builtin.zig_backend == .stage2_c and builtin.os.tag == .windows) return error.SkipZigTest; // MSVC doesn't support tail call modifiers
30
3031 const foo = struct {
31 fn foo() i32 {
32 fn foo(_: i32) i32 {
3233 return 1234;
3334 }
3435 }.foo;
35 try expect(@call(.auto, foo, .{}) == 1234);
36 try expect(@call(.auto, foo, .{1}) == 1234);
3637 comptime {
37 // modifiers that allow comptime calls
38 try expect(@call(.auto, foo, .{}) == 1234);
39 try expect(@call(.no_async, foo, .{}) == 1234);
40 try expect(@call(.always_tail, foo, .{}) == 1234);
41 try expect(@call(.always_inline, foo, .{}) == 1234);
38 // comptime calls with supported modifiers
39 try expect(@call(.auto, foo, .{2}) == 1234);
40 try expect(@call(.no_async, foo, .{3}) == 1234);
41 try expect(@call(.always_tail, foo, .{4}) == 1234);
42 try expect(@call(.always_inline, foo, .{5}) == 1234);
4243 }
43 {
44 // comptime call without comptime keyword
45 const result = @call(.compile_time, foo, .{}) == 1234;
46 comptime assert(result);
47 }
48 {
49 // call of non comptime-known function
44 // comptime call without comptime keyword
45 const result = @call(.compile_time, foo, .{6}) == 1234;
46 comptime assert(result);
47 // runtime calls of comptime-known function
48 try expect(@call(.no_async, foo, .{7}) == 1234);
49 try expect(@call(.never_tail, foo, .{8}) == 1234);
50 try expect(@call(.never_inline, foo, .{9}) == 1234);
51 // CBE does not support attributes on runtime functions
52 if (builtin.zig_backend != .stage2_c) {
53 // runtime calls of non comptime-known function
5054 var alias_foo = &foo;
5155 _ = &alias_foo;
52 try expect(@call(.no_async, alias_foo, .{}) == 1234);
53 try expect(@call(.never_tail, alias_foo, .{}) == 1234);
54 try expect(@call(.never_inline, alias_foo, .{}) == 1234);
56 try expect(@call(.no_async, alias_foo, .{10}) == 1234);
57 try expect(@call(.never_tail, alias_foo, .{11}) == 1234);
58 try expect(@call(.never_inline, alias_foo, .{12}) == 1234);
5559 }
5660}
5761