| ... | ... | @@ -106,7 +106,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 106 | 106 | \\static void bar(void) {} |
| 107 | 107 | , &[_][]const u8{ |
| 108 | 108 | \\pub export fn foo() void {} |
| 109 | | \\pub fn bar() void {} |
| 109 | \\pub fn bar() callconv(.C) void {} |
| 110 | 110 | }); |
| 111 | 111 | |
| 112 | 112 | cases.add("typedef void", |
| ... | ... | @@ -843,6 +843,38 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 843 | 843 | \\pub const fn1 = ?extern fn (u8) void; |
| 844 | 844 | }); |
| 845 | 845 | |
| 846 | cases.addWithTarget("Calling convention", tests.Target{ |
| 847 | .Cross = .{ .os = .linux, .arch = .i386, .abi = .none }, |
| 848 | }, |
| 849 | \\void __attribute__((fastcall)) foo1(float *a); |
| 850 | \\void __attribute__((stdcall)) foo2(float *a); |
| 851 | \\void __attribute__((vectorcall)) foo3(float *a); |
| 852 | \\void __attribute__((cdecl)) foo4(float *a); |
| 853 | , &[_][]const u8{ |
| 854 | \\pub fn foo1(a: [*c]f32) callconv(.Fastcall) void; |
| 855 | \\pub fn foo2(a: [*c]f32) callconv(.Stdcall) void; |
| 856 | \\pub fn foo3(a: [*c]f32) callconv(.Vectorcall) void; |
| 857 | \\pub extern fn foo4(a: [*c]f32) void; |
| 858 | }); |
| 859 | |
| 860 | cases.addWithTarget("Calling convention", tests.Target{ |
| 861 | .Cross = .{ .os = .linux, .arch = .{ .arm = .v8_5a }, .abi = .none }, |
| 862 | }, |
| 863 | \\void __attribute__((pcs("aapcs"))) foo1(float *a); |
| 864 | \\void __attribute__((pcs("aapcs-vfp"))) foo2(float *a); |
| 865 | , &[_][]const u8{ |
| 866 | \\pub fn foo1(a: [*c]f32) callconv(.AAPCS) void; |
| 867 | \\pub fn foo2(a: [*c]f32) callconv(.AAPCSVFP) void; |
| 868 | }); |
| 869 | |
| 870 | cases.addWithTarget("Calling convention", tests.Target{ |
| 871 | .Cross = .{ .os = .linux, .arch = .{ .aarch64 = .v8_5a }, .abi = .none }, |
| 872 | }, |
| 873 | \\void __attribute__((aarch64_vector_pcs)) foo1(float *a); |
| 874 | , &[_][]const u8{ |
| 875 | \\pub fn foo1(a: [*c]f32) callconv(.Vectorcall) void; |
| 876 | }); |
| 877 | |
| 846 | 878 | cases.add("Parameterless function prototypes", |
| 847 | 879 | \\void a() {} |
| 848 | 880 | \\void b(void) {} |
| ... | ... | @@ -871,7 +903,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 871 | 903 | \\ char *arr1[10] ={0}; |
| 872 | 904 | \\} |
| 873 | 905 | , &[_][]const u8{ |
| 874 | | \\pub fn foo() void { |
| 906 | \\pub fn foo() callconv(.C) void { |
| 875 | 907 | \\ var arr: [10]u8 = .{ |
| 876 | 908 | \\ @bitCast(u8, @truncate(i8, @as(c_int, 1))), |
| 877 | 909 | \\ } ++ .{0} ** 9; |
| ... | ... | @@ -2148,7 +2180,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 2148 | 2180 | \\ baz(); |
| 2149 | 2181 | \\} |
| 2150 | 2182 | , &[_][]const u8{ |
| 2151 | | \\pub fn bar() void {} |
| 2183 | \\pub fn bar() callconv(.C) void {} |
| 2152 | 2184 | \\pub export fn foo(arg_baz: ?extern fn () [*c]c_int) void { |
| 2153 | 2185 | \\ var baz = arg_baz; |
| 2154 | 2186 | \\ bar(); |