aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2020-01-06 18:53:17 -0500
committerAndrew Kelley <andrew@ziglang.org>2020-01-06 18:53:17 -0500
commit633b6bf92055a62f8a18dbfdb1ddc4f7330bf4ec (patch)
tree3be9c09b1e6c0c3aff43fdc3d6d98948756de023 /test
parent4e6ad8efd9fcefb820acf4a03fc4ab9157f85c1b (diff)
parentc0e8837ce9168088e89bfeef9516d7318cd5f97d (diff)
downloadzig-633b6bf92055a62f8a18dbfdb1ddc4f7330bf4ec.tar.gz
zig-633b6bf92055a62f8a18dbfdb1ddc4f7330bf4ec.zip
Merge branch 'LemonBoy-cc-work'
Diffstat (limited to 'test')
-rw-r--r--test/compile_errors.zig40
-rw-r--r--test/src/translate_c.zig14
-rw-r--r--test/stage1/behavior/align.zig6
-rw-r--r--test/stage1/behavior/bugs/1310.zig4
-rw-r--r--test/stage1/behavior/cast.zig4
-rw-r--r--test/stage1/behavior/fn.zig4
-rw-r--r--test/stage1/behavior/misc.zig2
-rw-r--r--test/stage1/behavior/struct.zig4
-rw-r--r--test/stage1/behavior/type_info.zig4
-rw-r--r--test/standalone/load_dynamic_library/main.zig2
-rw-r--r--test/translate_c.zig76
11 files changed, 104 insertions, 56 deletions
diff --git a/test/compile_errors.zig b/test/compile_errors.zig
index 75e88ac918..fb1cf88e74 100644
--- a/test/compile_errors.zig
+++ b/test/compile_errors.zig
@@ -752,7 +752,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
\\ _ = @frame();
\\}
, &[_][]const u8{
- "tmp.zig:1:1: error: function with calling convention 'ccc' cannot be async",
+ "tmp.zig:1:1: error: function with calling convention 'C' cannot be async",
"tmp.zig:5:9: note: @frame() causes function to be async",
});
@@ -765,7 +765,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
\\ suspend;
\\}
, &[_][]const u8{
- "tmp.zig:1:1: error: function with calling convention 'ccc' cannot be async",
+ "tmp.zig:1:1: error: function with calling convention 'C' cannot be async",
"tmp.zig:3:18: note: await here is a suspend point",
});
@@ -843,7 +843,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
\\ suspend;
\\}
, &[_][]const u8{
- "tmp.zig:1:1: error: function with calling convention 'ccc' cannot be async",
+ "tmp.zig:1:1: error: function with calling convention 'C' cannot be async",
"tmp.zig:2:8: note: async function call here",
"tmp.zig:5:8: note: async function call here",
"tmp.zig:8:5: note: suspends here",
@@ -1140,7 +1140,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
\\ while (true) {}
\\}
, &[_][]const u8{
- "error: expected type 'fn([]const u8, ?*std.builtin.StackTrace) noreturn', found 'fn([]const u8,var)var'",
+ "error: expected type 'fn([]const u8, ?*std.builtin.StackTrace) noreturn', found 'fn([]const u8,var) var'",
"note: only one of the functions is generic",
});
@@ -1362,7 +1362,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
\\ return 0;
\\}
, &[_][]const u8{
- "tmp.zig:1:15: error: parameter of type 'var' not allowed in function with calling convention 'ccc'",
+ "tmp.zig:1:15: error: parameter of type 'var' not allowed in function with calling convention 'C'",
});
cases.add("C pointer to c_void",
@@ -2187,7 +2187,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
\\ f(g);
\\}
, &[_][]const u8{
- "tmp.zig:1:9: error: parameter of type 'fn(var)var' must be declared comptime",
+ "tmp.zig:1:9: error: parameter of type 'fn(var) var' must be declared comptime",
});
cases.add("optional pointer to void in extern struct",
@@ -2843,7 +2843,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
\\export fn entry() void {
\\ foo();
\\}
- \\nakedcc fn foo() void { }
+ \\fn foo() callconv(.Naked) void { }
, &[_][]const u8{
"tmp.zig:2:5: error: unable to call function with naked calling convention",
"tmp.zig:4:1: note: declared here",
@@ -2859,7 +2859,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
\\const Foo = enum { A, B, C };
\\export fn entry(foo: Foo) void { }
, &[_][]const u8{
- "tmp.zig:2:22: error: parameter of type 'Foo' not allowed in function with calling convention 'ccc'",
+ "tmp.zig:2:22: error: parameter of type 'Foo' not allowed in function with calling convention 'C'",
});
cases.add("function with non-extern non-packed struct parameter",
@@ -2870,7 +2870,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
\\};
\\export fn entry(foo: Foo) void { }
, &[_][]const u8{
- "tmp.zig:6:22: error: parameter of type 'Foo' not allowed in function with calling convention 'ccc'",
+ "tmp.zig:6:22: error: parameter of type 'Foo' not allowed in function with calling convention 'C'",
});
cases.add("function with non-extern non-packed union parameter",
@@ -2881,7 +2881,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
\\};
\\export fn entry(foo: Foo) void { }
, &[_][]const u8{
- "tmp.zig:6:22: error: parameter of type 'Foo' not allowed in function with calling convention 'ccc'",
+ "tmp.zig:6:22: error: parameter of type 'Foo' not allowed in function with calling convention 'C'",
});
cases.add("switch on enum with 1 field with no prongs",
@@ -2972,13 +2972,13 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
\\ foo(bar);
\\}
\\
- \\extern fn bar(x: *void) void { }
+ \\fn bar(x: *void) callconv(.C) void { }
\\export fn entry2() void {
\\ bar(&{});
\\}
, &[_][]const u8{
- "tmp.zig:1:30: error: parameter of type '*void' has 0 bits; not allowed in function with calling convention 'ccc'",
- "tmp.zig:7:18: error: parameter of type '*void' has 0 bits; not allowed in function with calling convention 'ccc'",
+ "tmp.zig:1:30: error: parameter of type '*void' has 0 bits; not allowed in function with calling convention 'C'",
+ "tmp.zig:7:11: error: parameter of type '*void' has 0 bits; not allowed in function with calling convention 'C'",
});
cases.add("implicit semicolon - block statement",
@@ -3871,7 +3871,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
\\
\\export fn entry() usize { return @sizeOf(@TypeOf(fns)); }
, &[_][]const u8{
- "tmp.zig:1:37: error: expected type 'fn(i32) i32', found 'extern fn(i32) i32'",
+ "tmp.zig:1:37: error: expected type 'fn(i32) i32', found 'fn(i32) callconv(.C) i32'",
});
cases.add("colliding invalid top level functions",
@@ -4552,7 +4552,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
\\ return x + y;
\\}
, &[_][]const u8{
- "tmp.zig:1:15: error: comptime parameter not allowed in function with calling convention 'ccc'",
+ "tmp.zig:1:15: error: comptime parameter not allowed in function with calling convention 'C'",
});
cases.add("extern function with comptime parameter",
@@ -4562,7 +4562,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
\\}
\\export fn entry() usize { return @sizeOf(@TypeOf(f)); }
, &[_][]const u8{
- "tmp.zig:1:15: error: comptime parameter not allowed in function with calling convention 'ccc'",
+ "tmp.zig:1:15: error: comptime parameter not allowed in function with calling convention 'C'",
});
cases.add("convert fixed size array to slice with invalid size",
@@ -5618,7 +5618,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
});
cases.add("wrong types given to @export",
- \\extern fn entry() void { }
+ \\fn entry() callconv(.C) void { }
\\comptime {
\\ @export("entry", entry, @as(u32, 1234));
\\}
@@ -5663,7 +5663,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
});
cases.add("@setAlignStack in naked function",
- \\export nakedcc fn entry() void {
+ \\export fn entry() callconv(.Naked) void {
\\ @setAlignStack(16);
\\}
, &[_][]const u8{
@@ -6303,7 +6303,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
\\ _ = @TypeOf(generic).ReturnType;
\\}
, &[_][]const u8{
- "tmp.zig:3:25: error: ReturnType has not been resolved because 'fn(var)var' is generic",
+ "tmp.zig:3:25: error: ReturnType has not been resolved because 'fn(var) var' is generic",
});
cases.add("getting @ArgType of generic function",
@@ -6312,7 +6312,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
\\ _ = @ArgType(@TypeOf(generic), 0);
\\}
, &[_][]const u8{
- "tmp.zig:3:36: error: @ArgType could not resolve the type of arg 0 because 'fn(var)var' is generic",
+ "tmp.zig:3:36: error: @ArgType could not resolve the type of arg 0 because 'fn(var) var' is generic",
});
cases.add("unsupported modifier at start of asm output constraint",
diff --git a/test/src/translate_c.zig b/test/src/translate_c.zig
index 6db1e6f181..ad820dcec6 100644
--- a/test/src/translate_c.zig
+++ b/test/src/translate_c.zig
@@ -19,6 +19,7 @@ pub const TranslateCContext = struct {
sources: ArrayList(SourceFile),
expected_lines: ArrayList([]const u8),
allow_warnings: bool,
+ target: std.Target = .Native,
const SourceFile = struct {
filename: []const u8,
@@ -71,6 +72,18 @@ pub const TranslateCContext = struct {
self.addCase(tc);
}
+ pub fn addWithTarget(
+ self: *TranslateCContext,
+ name: []const u8,
+ target: std.Target,
+ source: []const u8,
+ expected_lines: []const []const u8,
+ ) void {
+ const tc = self.create(false, "source.h", name, source, expected_lines);
+ tc.target = target;
+ self.addCase(tc);
+ }
+
pub fn addAllowWarnings(
self: *TranslateCContext,
name: []const u8,
@@ -101,6 +114,7 @@ pub const TranslateCContext = struct {
.basename = case.sources.toSliceConst()[0].filename,
},
});
+ translate_c.setTarget(case.target);
const check_file = translate_c.addCheckFile(case.expected_lines.toSliceConst());
diff --git a/test/stage1/behavior/align.zig b/test/stage1/behavior/align.zig
index 1812394f2e..c83d2379b4 100644
--- a/test/stage1/behavior/align.zig
+++ b/test/stage1/behavior/align.zig
@@ -221,14 +221,14 @@ test "alignment of structs" {
}) == @alignOf(usize));
}
-test "alignment of extern() void" {
+test "alignment of function with c calling convention" {
var runtime_nothing = nothing;
const casted1 = @ptrCast(*const u8, runtime_nothing);
- const casted2 = @ptrCast(extern fn () void, casted1);
+ const casted2 = @ptrCast(fn () callconv(.C) void, casted1);
casted2();
}
-extern fn nothing() void {}
+fn nothing() callconv(.C) void {}
test "return error union with 128-bit integer" {
expect(3 == try give());
diff --git a/test/stage1/behavior/bugs/1310.zig b/test/stage1/behavior/bugs/1310.zig
index f0f696e4bc..788cba5756 100644
--- a/test/stage1/behavior/bugs/1310.zig
+++ b/test/stage1/behavior/bugs/1310.zig
@@ -3,7 +3,7 @@ const expect = std.testing.expect;
pub const VM = ?[*]const struct_InvocationTable_;
pub const struct_InvocationTable_ = extern struct {
- GetVM: ?extern fn (?[*]VM) c_int,
+ GetVM: ?fn (?[*]VM) callconv(.C) c_int,
};
pub const struct_VM_ = extern struct {
@@ -15,7 +15,7 @@ pub const struct_VM_ = extern struct {
pub const InvocationTable_ = struct_InvocationTable_;
pub const VM_ = struct_VM_;
-extern fn agent_callback(_vm: [*]VM, options: [*]u8) i32 {
+fn agent_callback(_vm: [*]VM, options: [*]u8) callconv(.C) i32 {
return 11;
}
diff --git a/test/stage1/behavior/cast.zig b/test/stage1/behavior/cast.zig
index aca8c6fc34..ae2530af61 100644
--- a/test/stage1/behavior/cast.zig
+++ b/test/stage1/behavior/cast.zig
@@ -477,7 +477,7 @@ test "compile time int to ptr of function" {
}
pub const FUNCTION_CONSTANT = @intToPtr(PFN_void, maxInt(usize));
-pub const PFN_void = extern fn (*c_void) void;
+pub const PFN_void = fn (*c_void) callconv(.C) void;
fn foobar(func: PFN_void) void {
std.testing.expect(@ptrToInt(func) == maxInt(usize));
@@ -587,7 +587,7 @@ test "peer cast *[0]T to []const T" {
var global_array: [4]u8 = undefined;
test "cast from array reference to fn" {
- const f = @ptrCast(extern fn () void, &global_array);
+ const f = @ptrCast(fn () callconv(.C) void, &global_array);
expect(@ptrToInt(f) == @ptrToInt(&global_array));
}
diff --git a/test/stage1/behavior/fn.zig b/test/stage1/behavior/fn.zig
index 654405df44..13859b92ca 100644
--- a/test/stage1/behavior/fn.zig
+++ b/test/stage1/behavior/fn.zig
@@ -186,9 +186,9 @@ test "return inner function which references comptime variable of outer function
test "extern struct with stdcallcc fn pointer" {
const S = extern struct {
- ptr: stdcallcc fn () i32,
+ ptr: fn () callconv(.Stdcall) i32,
- stdcallcc fn foo() i32 {
+ fn foo() callconv(.Stdcall) i32 {
return 1234;
}
};
diff --git a/test/stage1/behavior/misc.zig b/test/stage1/behavior/misc.zig
index 0b29189cde..9b9771a24c 100644
--- a/test/stage1/behavior/misc.zig
+++ b/test/stage1/behavior/misc.zig
@@ -19,7 +19,7 @@ comptime {
@export("disabledExternFn", disabledExternFn, builtin.GlobalLinkage.Internal);
}
-extern fn disabledExternFn() void {}
+fn disabledExternFn() callconv(.C) void {}
test "call disabled extern fn" {
disabledExternFn();
diff --git a/test/stage1/behavior/struct.zig b/test/stage1/behavior/struct.zig
index 2d51498a85..8e5ab29db3 100644
--- a/test/stage1/behavior/struct.zig
+++ b/test/stage1/behavior/struct.zig
@@ -580,7 +580,7 @@ test "default struct initialization fields" {
expectEqual(1239, x.a + x.b);
}
-test "extern fn returns struct by value" {
+test "fn with C calling convention returns struct by value" {
const S = struct {
fn entry() void {
var x = makeBar(10);
@@ -591,7 +591,7 @@ test "extern fn returns struct by value" {
handle: i32,
};
- extern fn makeBar(t: i32) ExternBar {
+ fn makeBar(t: i32) callconv(.C) ExternBar {
return ExternBar{
.handle = t,
};
diff --git a/test/stage1/behavior/type_info.zig b/test/stage1/behavior/type_info.zig
index a9d4a1c924..d35cc8831f 100644
--- a/test/stage1/behavior/type_info.zig
+++ b/test/stage1/behavior/type_info.zig
@@ -202,7 +202,7 @@ fn testUnion() void {
expect(typeinfo_info.Union.fields[4].enum_field != null);
expect(typeinfo_info.Union.fields[4].enum_field.?.value == 4);
expect(typeinfo_info.Union.fields[4].field_type == @TypeOf(@typeInfo(u8).Int));
- expect(typeinfo_info.Union.decls.len == 21);
+ expect(typeinfo_info.Union.decls.len == 20);
const TestNoTagUnion = union {
Foo: void,
@@ -266,7 +266,7 @@ test "type info: function type info" {
fn testFunction() void {
const fn_info = @typeInfo(@TypeOf(foo));
expect(@as(TypeId, fn_info) == TypeId.Fn);
- expect(fn_info.Fn.calling_convention == TypeInfo.CallingConvention.Unspecified);
+ expect(fn_info.Fn.calling_convention == .Unspecified);
expect(fn_info.Fn.is_generic);
expect(fn_info.Fn.args.len == 2);
expect(fn_info.Fn.is_var_args);
diff --git a/test/standalone/load_dynamic_library/main.zig b/test/standalone/load_dynamic_library/main.zig
index d1cba72db5..197e3ca47c 100644
--- a/test/standalone/load_dynamic_library/main.zig
+++ b/test/standalone/load_dynamic_library/main.zig
@@ -9,7 +9,7 @@ pub fn main() !void {
var lib = try std.DynLib.open(dynlib_name);
defer lib.close();
- const addFn = lib.lookup(extern fn (i32, i32) i32, "add") orelse return error.SymbolNotFound;
+ const addFn = lib.lookup(fn (i32, i32) callconv(.C) i32, "add") orelse return error.SymbolNotFound;
const result = addFn(12, 34);
std.debug.assert(result == 46);
diff --git a/test/translate_c.zig b/test/translate_c.zig
index 7049173d80..3714d370eb 100644
--- a/test/translate_c.zig
+++ b/test/translate_c.zig
@@ -205,7 +205,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
\\static void bar(void) {}
, &[_][]const u8{
\\pub export fn foo() void {}
- \\pub fn bar() void {}
+ \\pub fn bar() callconv(.C) void {}
});
cases.add("typedef void",
@@ -238,7 +238,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
\\pub extern fn foo() void;
\\pub export fn bar() void {
\\ var func_ptr: ?*c_void = @ptrCast(?*c_void, foo);
- \\ var typed_func_ptr: ?extern fn () void = @intToPtr(?extern fn () void, @intCast(c_ulong, @ptrToInt(func_ptr)));
+ \\ var typed_func_ptr: ?fn () callconv(.C) void = @intToPtr(?fn () callconv(.C) void, @intCast(c_ulong, @ptrToInt(func_ptr)));
\\}
});
@@ -295,9 +295,9 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
\\ lws_callback_function *callback_http;
\\};
, &[_][]const u8{
- \\pub const lws_callback_function = extern fn () void;
+ \\pub const lws_callback_function = fn () callconv(.C) void;
\\pub const struct_Foo = extern struct {
- \\ func: ?extern fn () void,
+ \\ func: ?fn () callconv(.C) void,
\\ callback_http: ?lws_callback_function,
\\};
});
@@ -377,7 +377,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
\\};
, &[_][]const u8{
\\pub const struct_Foo = extern struct {
- \\ derp: ?extern fn ([*c]struct_Foo) void,
+ \\ derp: ?fn ([*c]struct_Foo) callconv(.C) void,
\\};
,
\\pub const Foo = struct_Foo;
@@ -611,7 +611,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
cases.add("__cdecl doesn't mess up function pointers",
\\void foo(void (__cdecl *fn_ptr)(void));
, &[_][]const u8{
- \\pub extern fn foo(fn_ptr: ?extern fn () void) void;
+ \\pub extern fn foo(fn_ptr: ?fn () callconv(.C) void) void;
});
cases.add("void cast",
@@ -953,8 +953,42 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
\\typedef void (*fn0)();
\\typedef void (*fn1)(char);
, &[_][]const u8{
- \\pub const fn0 = ?extern fn (...) void;
- \\pub const fn1 = ?extern fn (u8) void;
+ \\pub const fn0 = ?fn (...) callconv(.C) void;
+ \\pub const fn1 = ?fn (u8) callconv(.C) void;
+ });
+
+ cases.addWithTarget("Calling convention", tests.Target{
+ .Cross = .{ .os = .linux, .arch = .i386, .abi = .none },
+ },
+ \\void __attribute__((fastcall)) foo1(float *a);
+ \\void __attribute__((stdcall)) foo2(float *a);
+ \\void __attribute__((vectorcall)) foo3(float *a);
+ \\void __attribute__((cdecl)) foo4(float *a);
+ \\void __attribute__((thiscall)) foo5(float *a);
+ , &[_][]const u8{
+ \\pub fn foo1(a: [*c]f32) callconv(.Fastcall) void;
+ \\pub fn foo2(a: [*c]f32) callconv(.Stdcall) void;
+ \\pub fn foo3(a: [*c]f32) callconv(.Vectorcall) void;
+ \\pub extern fn foo4(a: [*c]f32) void;
+ \\pub fn foo5(a: [*c]f32) callconv(.Thiscall) void;
+ });
+
+ cases.addWithTarget("Calling convention", tests.Target{
+ .Cross = .{ .os = .linux, .arch = .{ .arm = .v8_5a }, .abi = .none },
+ },
+ \\void __attribute__((pcs("aapcs"))) foo1(float *a);
+ \\void __attribute__((pcs("aapcs-vfp"))) foo2(float *a);
+ , &[_][]const u8{
+ \\pub fn foo1(a: [*c]f32) callconv(.AAPCS) void;
+ \\pub fn foo2(a: [*c]f32) callconv(.AAPCSVFP) void;
+ });
+
+ cases.addWithTarget("Calling convention", tests.Target{
+ .Cross = .{ .os = .linux, .arch = .{ .aarch64 = .v8_5a }, .abi = .none },
+ },
+ \\void __attribute__((aarch64_vector_pcs)) foo1(float *a);
+ , &[_][]const u8{
+ \\pub fn foo1(a: [*c]f32) callconv(.Vectorcall) void;
});
cases.add("Parameterless function prototypes",
@@ -985,7 +1019,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
\\ char *arr1[10] ={0};
\\}
, &[_][]const u8{
- \\pub fn foo() void {
+ \\pub fn foo() callconv(.C) void {
\\ var arr: [10]u8 = .{
\\ @bitCast(u8, @truncate(i8, @as(c_int, 1))),
\\ } ++ .{0} ** 9;
@@ -1123,13 +1157,13 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
\\extern char (*fn_ptr2)(int, float);
\\#define bar fn_ptr2
, &[_][]const u8{
- \\pub extern var fn_ptr: ?extern fn () void;
+ \\pub extern var fn_ptr: ?fn () callconv(.C) void;
,
\\pub inline fn foo() void {
\\ return fn_ptr.?();
\\}
,
- \\pub extern var fn_ptr2: ?extern fn (c_int, f32) u8;
+ \\pub extern var fn_ptr2: ?fn (c_int, f32) callconv(.C) u8;
,
\\pub inline fn bar(arg_1: c_int, arg_2: f32) u8 {
\\ return fn_ptr2.?(arg_1, arg_2);
@@ -1151,8 +1185,8 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
\\#define glClearPFN PFNGLCLEARPROC
, &[_][]const u8{
\\pub const GLbitfield = c_uint;
- \\pub const PFNGLCLEARPROC = ?extern fn (GLbitfield) void;
- \\pub const OpenGLProc = ?extern fn () void;
+ \\pub const PFNGLCLEARPROC = ?fn (GLbitfield) callconv(.C) void;
+ \\pub const OpenGLProc = ?fn () callconv(.C) void;
\\const struct_unnamed_1 = extern struct {
\\ Clear: PFNGLCLEARPROC,
\\};
@@ -1942,8 +1976,8 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
\\ return 0;
\\}
\\pub export fn bar() void {
- \\ var f: ?extern fn () void = foo;
- \\ var b: ?extern fn () c_int = baz;
+ \\ var f: ?fn () callconv(.C) void = foo;
+ \\ var b: ?fn () callconv(.C) c_int = baz;
\\ f.?();
\\ (f).?();
\\ foo();
@@ -2262,8 +2296,8 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
\\ baz();
\\}
, &[_][]const u8{
- \\pub fn bar() void {}
- \\pub export fn foo(arg_baz: ?extern fn () [*c]c_int) void {
+ \\pub fn bar() callconv(.C) void {}
+ \\pub export fn foo(arg_baz: ?fn () callconv(.C) [*c]c_int) void {
\\ var baz = arg_baz;
\\ bar();
\\ _ = baz.?();
@@ -2321,7 +2355,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
\\ do {} while (0);
\\}
, &[_][]const u8{
- \\pub fn foo() void {
+ \\pub fn foo() callconv(.C) void {
\\ if (@as(c_int, 1) != 0) while (true) {
\\ if (!(@as(c_int, 0) != 0)) break;
\\ };
@@ -2413,9 +2447,9 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
\\void c(void) {}
\\static void foo() {}
, &[_][]const u8{
- \\pub fn a() void {}
- \\pub fn b() void {}
+ \\pub fn a() callconv(.C) void {}
+ \\pub fn b() callconv(.C) void {}
\\pub export fn c() void {}
- \\pub fn foo() void {}
+ \\pub fn foo() callconv(.C) void {}
});
}