authorgravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2024-10-13 17:56:47+01:00
committergravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2024-10-19 19:15:23+01:00
log4be0cf30fc10420c2b5fa97a3b25a07b7a0ce7f3
tree0c239f9b68fbbc13ae94462756d466ef774a9772
parentec19086aa0491024622c444b0d9310560de9e6f0
signaturelock-open Commit is signed but in an unrecognized format.

test: update for `CallingConvention` changes

This also includes some compiler and std changes to correct error messages which weren't properly updated before.

41 files changed, 154 insertions(+), 195 deletions(-)

lib/std/Target.zig+1-1
...@@ -1612,7 +1612,7 @@ pub const Cpu = struct {...@@ -1612,7 +1612,7 @@ pub const Cpu = struct {
16121612
1613 /// Returns the array of `Arch` to which a specific `std.builtin.CallingConvention` applies.1613 /// Returns the array of `Arch` to which a specific `std.builtin.CallingConvention` applies.
1614 /// Asserts that `cc` is not `.auto`, `.@"async"`, `.naked`, or `.@"inline"`.1614 /// Asserts that `cc` is not `.auto`, `.@"async"`, `.naked`, or `.@"inline"`.
1615 pub fn fromCallconv(cc: std.builtin.CallingConvention) []const Arch {1615 pub fn fromCallconv(cc: std.builtin.CallingConvention.Tag) []const Arch {
1616 return switch (cc) {1616 return switch (cc) {
1617 .auto,1617 .auto,
1618 .@"async",1618 .@"async",
lib/std/builtin.zig+5-3
...@@ -173,7 +173,7 @@ pub const CallingConvention = union(enum(u8)) {...@@ -173,7 +173,7 @@ pub const CallingConvention = union(enum(u8)) {
173 /// Functions marked as `extern` or `export` are given this calling convention by default.173 /// Functions marked as `extern` or `export` are given this calling convention by default.
174 pub const c = builtin.target.defaultCCallingConvention().?;174 pub const c = builtin.target.defaultCCallingConvention().?;
175175
176 pub const winapi: CallingConvention = switch (builtin.target.arch) {176 pub const winapi: CallingConvention = switch (builtin.target.cpu.arch) {
177 .x86_64 => .{ .x86_64_win = .{} },177 .x86_64 => .{ .x86_64_win = .{} },
178 .x86 => .{ .x86_stdcall = .{} },178 .x86 => .{ .x86_stdcall = .{} },
179 .aarch64, .aarch64_be => .{ .aarch64_aapcs_win = .{} },179 .aarch64, .aarch64_be => .{ .aarch64_aapcs_win = .{} },
...@@ -481,7 +481,9 @@ pub const CallingConvention = union(enum(u8)) {...@@ -481,7 +481,9 @@ pub const CallingConvention = union(enum(u8)) {
481481
482 /// Returns the array of `std.Target.Cpu.Arch` to which this `CallingConvention` applies.482 /// Returns the array of `std.Target.Cpu.Arch` to which this `CallingConvention` applies.
483 /// Asserts that `cc` is not `.auto`, `.@"async"`, `.naked`, or `.@"inline"`.483 /// Asserts that `cc` is not `.auto`, `.@"async"`, `.naked`, or `.@"inline"`.
484 pub const archs = std.Target.Cpu.Arch.fromCallconv;484 pub fn archs(cc: CallingConvention) []const std.Target.Cpu.Arch {
485 return std.Target.Cpu.Arch.fromCallconv(cc);
486 }
485487
486 pub fn eql(a: CallingConvention, b: CallingConvention) bool {488 pub fn eql(a: CallingConvention, b: CallingConvention) bool {
487 return std.meta.eql(a, b);489 return std.meta.eql(a, b);
...@@ -490,7 +492,7 @@ pub const CallingConvention = union(enum(u8)) {...@@ -490,7 +492,7 @@ pub const CallingConvention = union(enum(u8)) {
490 pub fn withStackAlign(cc: CallingConvention, incoming_stack_alignment: u64) CallingConvention {492 pub fn withStackAlign(cc: CallingConvention, incoming_stack_alignment: u64) CallingConvention {
491 const tag: CallingConvention.Tag = cc;493 const tag: CallingConvention.Tag = cc;
492 var result = cc;494 var result = cc;
493 @field(result, tag).incoming_stack_alignment = incoming_stack_alignment;495 @field(result, @tagName(tag)).incoming_stack_alignment = incoming_stack_alignment;
494 return result;496 return result;
495 }497 }
496};498};
src/Sema.zig+22-15
...@@ -9711,25 +9711,32 @@ fn callConvSupportsVarArgs(cc: std.builtin.CallingConvention.Tag) bool {...@@ -9711,25 +9711,32 @@ fn callConvSupportsVarArgs(cc: std.builtin.CallingConvention.Tag) bool {
9711}9711}
9712fn checkCallConvSupportsVarArgs(sema: *Sema, block: *Block, src: LazySrcLoc, cc: std.builtin.CallingConvention.Tag) CompileError!void {9712fn checkCallConvSupportsVarArgs(sema: *Sema, block: *Block, src: LazySrcLoc, cc: std.builtin.CallingConvention.Tag) CompileError!void {
9713 const CallingConventionsSupportingVarArgsList = struct {9713 const CallingConventionsSupportingVarArgsList = struct {
9714 pub fn format(_: @This(), comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: anytype) !void {9714 arch: std.Target.Cpu.Arch,
9715 pub fn format(ctx: @This(), comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: anytype) !void {
9715 _ = fmt;9716 _ = fmt;
9716 _ = options;9717 _ = options;
9717 for (calling_conventions_supporting_var_args, 0..) |cc_inner, i| {9718 var first = true;
9718 if (i != 0)9719 for (calling_conventions_supporting_var_args) |cc_inner| {
9720 for (std.Target.Cpu.Arch.fromCallconv(cc_inner)) |supported_arch| {
9721 if (supported_arch == ctx.arch) break;
9722 } else continue; // callconv not supported by this arch
9723 if (!first) {
9719 try writer.writeAll(", ");9724 try writer.writeAll(", ");
9720 try writer.print("'.{s}'", .{@tagName(cc_inner)});9725 }
9726 first = false;
9727 try writer.print("'{s}'", .{@tagName(cc_inner)});
9721 }9728 }
9722 }9729 }
9723 };9730 };
97249731
9725 if (!callConvSupportsVarArgs(cc)) {9732 if (!callConvSupportsVarArgs(cc)) {
9726 const msg = msg: {9733 return sema.failWithOwnedErrorMsg(block, msg: {
9727 const msg = try sema.errMsg(src, "variadic function does not support '.{s}' calling convention", .{@tagName(cc)});9734 const msg = try sema.errMsg(src, "variadic function does not support '{s}' calling convention", .{@tagName(cc)});
9728 errdefer msg.destroy(sema.gpa);9735 errdefer msg.destroy(sema.gpa);
9729 try sema.errNote(src, msg, "supported calling conventions: {}", .{CallingConventionsSupportingVarArgsList{}});9736 const target = sema.pt.zcu.getTarget();
9737 try sema.errNote(src, msg, "supported calling conventions: {}", .{CallingConventionsSupportingVarArgsList{ .arch = target.cpu.arch }});
9730 break :msg msg;9738 break :msg msg;
9731 };9739 });
9732 return sema.failWithOwnedErrorMsg(block, msg);
9733 }9740 }
9734}9741}
97359742
...@@ -9857,9 +9864,9 @@ fn funcCommon(...@@ -9857,9 +9864,9 @@ fn funcCommon(
9857 .x86_64_interrupt, .x86_interrupt => {9864 .x86_64_interrupt, .x86_interrupt => {
9858 const err_code_size = target.ptrBitWidth();9865 const err_code_size = target.ptrBitWidth();
9859 switch (i) {9866 switch (i) {
9860 0 => if (param_ty.zigTypeTag(zcu) != .pointer) return sema.fail(block, param_src, "first parameter of function with 'Interrupt' calling convention must be a pointer type", .{}),9867 0 => if (param_ty.zigTypeTag(zcu) != .pointer) return sema.fail(block, param_src, "first parameter of function with '{s}' calling convention must be a pointer type", .{@tagName(cc_resolved)}),
9861 1 => if (param_ty.bitSize(zcu) != err_code_size) return sema.fail(block, param_src, "second parameter of function with 'Interrupt' calling convention must be a {d}-bit integer", .{err_code_size}),9868 1 => if (param_ty.bitSize(zcu) != err_code_size) return sema.fail(block, param_src, "second parameter of function with '{s}' calling convention must be a {d}-bit integer", .{ @tagName(cc_resolved), err_code_size }),
9862 else => return sema.fail(block, param_src, "'Interrupt' calling convention supports up to 2 parameters, found {d}", .{i + 1}),9869 else => return sema.fail(block, param_src, "'{s}' calling convention supports up to 2 parameters, found {d}", .{ @tagName(cc_resolved), i + 1 }),
9863 }9870 }
9864 },9871 },
9865 .arm_interrupt,9872 .arm_interrupt,
...@@ -9870,8 +9877,8 @@ fn funcCommon(...@@ -9870,8 +9877,8 @@ fn funcCommon(
9870 .avr_interrupt,9877 .avr_interrupt,
9871 .csky_interrupt,9878 .csky_interrupt,
9872 .m68k_interrupt,9879 .m68k_interrupt,
9873 => return sema.fail(block, param_src, "parameters are not allowed with 'Interrupt' calling convention", .{}),9880 => return sema.fail(block, param_src, "parameters are not allowed with '{s}' calling convention", .{@tagName(cc_resolved)}),
9874 .avr_signal => return sema.fail(block, param_src, "parameters are not allowed with 'Signal' calling convention", .{}),9881 .avr_signal => return sema.fail(block, param_src, "parameters are not allowed with '{s}' calling convention", .{@tagName(cc_resolved)}),
9875 else => {},9882 else => {},
9876 }9883 }
9877 }9884 }
...@@ -10220,7 +10227,7 @@ fn finishFunc(...@@ -10220,7 +10227,7 @@ fn finishFunc(
10220 for (formatter.archs, 0..) |arch, i| {10227 for (formatter.archs, 0..) |arch, i| {
10221 if (i != 0)10228 if (i != 0)
10222 try writer.writeAll(", ");10229 try writer.writeAll(", ");
10223 try writer.print("'.{s}'", .{@tagName(arch)});10230 try writer.print("'{s}'", .{@tagName(arch)});
10224 }10231 }
10225 }10232 }
10226 };10233 };
src/Type.zig+4-1
...@@ -397,7 +397,10 @@ pub fn print(ty: Type, writer: anytype, pt: Zcu.PerThread) @TypeOf(writer).Error...@@ -397,7 +397,10 @@ pub fn print(ty: Type, writer: anytype, pt: Zcu.PerThread) @TypeOf(writer).Error
397 break :print_cc;397 break :print_cc;
398 }398 }
399 }399 }
400 try writer.print("callconv({any}) ", .{fn_info.cc});400 switch (fn_info.cc) {
401 .auto, .@"async", .naked, .@"inline" => try writer.print("callconv(.{}) ", .{std.zig.fmtId(@tagName(fn_info.cc))}),
402 else => try writer.print("callconv({any}) ", .{fn_info.cc}),
403 }
401 }404 }
402 if (fn_info.return_type == .generic_poison_type) {405 if (fn_info.return_type == .generic_poison_type) {
403 try writer.writeAll("anytype");406 try writer.writeAll("anytype");
src/arch/riscv64/CodeGen.zig+2-1
...@@ -18,6 +18,7 @@ const Zcu = @import("../../Zcu.zig");...@@ -18,6 +18,7 @@ const Zcu = @import("../../Zcu.zig");
18const Package = @import("../../Package.zig");18const Package = @import("../../Package.zig");
19const InternPool = @import("../../InternPool.zig");19const InternPool = @import("../../InternPool.zig");
20const Compilation = @import("../../Compilation.zig");20const Compilation = @import("../../Compilation.zig");
21const target_util = @import("../../target.zig");
21const trace = @import("../../tracy.zig").trace;22const trace = @import("../../tracy.zig").trace;
22const codegen = @import("../../codegen.zig");23const codegen = @import("../../codegen.zig");
2324
...@@ -821,7 +822,7 @@ pub fn generate(...@@ -821,7 +822,7 @@ pub fn generate(
821 @intFromEnum(FrameIndex.stack_frame),822 @intFromEnum(FrameIndex.stack_frame),
822 FrameAlloc.init(.{823 FrameAlloc.init(.{
823 .size = 0,824 .size = 0,
824 .alignment = func.analysisUnordered(ip).stack_alignment.max(.@"1"),825 .alignment = .fromByteUnits(target_util.stackAlignment(function.target.*, fn_type.fnCallingConvention(zcu))),
825 }),826 }),
826 );827 );
827 function.frame_allocs.set(828 function.frame_allocs.set(
src/arch/x86_64/CodeGen.zig+1-1
...@@ -873,7 +873,7 @@ pub fn generate(...@@ -873,7 +873,7 @@ pub fn generate(
873 @intFromEnum(FrameIndex.stack_frame),873 @intFromEnum(FrameIndex.stack_frame),
874 FrameAlloc.init(.{874 FrameAlloc.init(.{
875 .size = 0,875 .size = 0,
876 .alignment = target_util.stackAlignment(function.target.*, fn_type.fnCallingConvention(zcu)),876 .alignment = .fromByteUnits(target_util.stackAlignment(function.target.*, fn_type.fnCallingConvention(zcu))),
877 }),877 }),
878 );878 );
879 function.frame_allocs.set(879 function.frame_allocs.set(
test/behavior/align.zig-9
...@@ -210,15 +210,6 @@ test "alignment and size of structs with 128-bit fields" {...@@ -210,15 +210,6 @@ test "alignment and size of structs with 128-bit fields" {
210 }210 }
211}211}
212212
213test "alignstack" {
214 try expect(fnWithAlignedStack() == 1234);
215}
216
217fn fnWithAlignedStack() i32 {
218 @setAlignStack(256);
219 return 1234;
220}
221
222test "implicitly decreasing slice alignment" {213test "implicitly decreasing slice alignment" {
223 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;214 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
224 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO215 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
test/behavior/builtin_functions_returning_void_or_noreturn.zig-1
...@@ -20,7 +20,6 @@ test {...@@ -20,7 +20,6 @@ test {
20 try testing.expectEqual({}, @memset(@as([*]u8, @ptrFromInt(1))[0..0], undefined));20 try testing.expectEqual({}, @memset(@as([*]u8, @ptrFromInt(1))[0..0], undefined));
21 try testing.expectEqual(noreturn, @TypeOf(if (true) @panic("") else {}));21 try testing.expectEqual(noreturn, @TypeOf(if (true) @panic("") else {}));
22 try testing.expectEqual({}, @prefetch(&val, .{}));22 try testing.expectEqual({}, @prefetch(&val, .{}));
23 try testing.expectEqual({}, @setAlignStack(16));
24 try testing.expectEqual({}, @setEvalBranchQuota(0));23 try testing.expectEqual({}, @setEvalBranchQuota(0));
25 try testing.expectEqual({}, @setFloatMode(.optimized));24 try testing.expectEqual({}, @setFloatMode(.optimized));
26 try testing.expectEqual({}, @setRuntimeSafety(true));25 try testing.expectEqual({}, @setRuntimeSafety(true));
test/behavior/type_info.zig+4-4
...@@ -358,7 +358,7 @@ test "type info: function type info" {...@@ -358,7 +358,7 @@ test "type info: function type info" {
358fn testFunction() !void {358fn testFunction() !void {
359 const foo_fn_type = @TypeOf(typeInfoFoo);359 const foo_fn_type = @TypeOf(typeInfoFoo);
360 const foo_fn_info = @typeInfo(foo_fn_type);360 const foo_fn_info = @typeInfo(foo_fn_type);
361 try expect(foo_fn_info.@"fn".calling_convention == .C);361 try expect(foo_fn_info.@"fn".calling_convention.eql(.c));
362 try expect(!foo_fn_info.@"fn".is_generic);362 try expect(!foo_fn_info.@"fn".is_generic);
363 try expect(foo_fn_info.@"fn".params.len == 2);363 try expect(foo_fn_info.@"fn".params.len == 2);
364 try expect(foo_fn_info.@"fn".is_var_args);364 try expect(foo_fn_info.@"fn".is_var_args);
...@@ -374,7 +374,7 @@ fn testFunction() !void {...@@ -374,7 +374,7 @@ fn testFunction() !void {
374374
375 const aligned_foo_fn_type = @TypeOf(typeInfoFooAligned);375 const aligned_foo_fn_type = @TypeOf(typeInfoFooAligned);
376 const aligned_foo_fn_info = @typeInfo(aligned_foo_fn_type);376 const aligned_foo_fn_info = @typeInfo(aligned_foo_fn_type);
377 try expect(aligned_foo_fn_info.@"fn".calling_convention == .C);377 try expect(aligned_foo_fn_info.@"fn".calling_convention.eql(.c));
378 try expect(!aligned_foo_fn_info.@"fn".is_generic);378 try expect(!aligned_foo_fn_info.@"fn".is_generic);
379 try expect(aligned_foo_fn_info.@"fn".params.len == 2);379 try expect(aligned_foo_fn_info.@"fn".params.len == 2);
380 try expect(aligned_foo_fn_info.@"fn".is_var_args);380 try expect(aligned_foo_fn_info.@"fn".is_var_args);
...@@ -390,8 +390,8 @@ fn testFunction() !void {...@@ -390,8 +390,8 @@ fn testFunction() !void {
390 try expect(aligned_foo_ptr_fn_info.pointer.sentinel == null);390 try expect(aligned_foo_ptr_fn_info.pointer.sentinel == null);
391}391}
392392
393extern fn typeInfoFoo(a: usize, b: bool, ...) callconv(.C) usize;393extern fn typeInfoFoo(a: usize, b: bool, ...) callconv(.c) usize;
394extern fn typeInfoFooAligned(a: usize, b: bool, ...) align(4) callconv(.C) usize;394extern fn typeInfoFooAligned(a: usize, b: bool, ...) align(4) callconv(.c) usize;
395395
396test "type info: generic function types" {396test "type info: generic function types" {
397 const G1 = @typeInfo(@TypeOf(generic1));397 const G1 = @typeInfo(@TypeOf(generic1));
test/behavior/typename.zig+3-3
...@@ -79,9 +79,9 @@ test "basic" {...@@ -79,9 +79,9 @@ test "basic" {
79 try expectEqualStrings("fn (comptime u32) void", @typeName(fn (comptime u32) void));79 try expectEqualStrings("fn (comptime u32) void", @typeName(fn (comptime u32) void));
80 try expectEqualStrings("fn (noalias []u8) void", @typeName(fn (noalias []u8) void));80 try expectEqualStrings("fn (noalias []u8) void", @typeName(fn (noalias []u8) void));
8181
82 try expectEqualStrings("fn () callconv(.C) void", @typeName(fn () callconv(.C) void));82 try expectEqualStrings("fn () callconv(.c) void", @typeName(fn () callconv(.c) void));
83 try expectEqualStrings("fn (...) callconv(.C) void", @typeName(fn (...) callconv(.C) void));83 try expectEqualStrings("fn (...) callconv(.c) void", @typeName(fn (...) callconv(.c) void));
84 try expectEqualStrings("fn (u32, ...) callconv(.C) void", @typeName(fn (u32, ...) callconv(.C) void));84 try expectEqualStrings("fn (u32, ...) callconv(.c) void", @typeName(fn (u32, ...) callconv(.c) void));
85}85}
8686
87test "top level decl" {87test "top level decl" {
test/cases/compile_errors/array_in_c_exported_function.zig+3-4
...@@ -7,10 +7,9 @@ export fn zig_return_array() [10]u8 {...@@ -7,10 +7,9 @@ export fn zig_return_array() [10]u8 {
7}7}
88
9// error9// error
10// backend=stage210// target=x86_64-linux
11// target=native
12//11//
13// :1:21: error: parameter of type '[10]u8' not allowed in function with calling convention 'C'12// :1:21: error: parameter of type '[10]u8' not allowed in function with calling convention 'x86_64_sysv'
14// :1:21: note: arrays are not allowed as a parameter type13// :1:21: note: arrays are not allowed as a parameter type
15// :5:30: error: return type '[10]u8' not allowed in function with calling convention 'C'14// :5:30: error: return type '[10]u8' not allowed in function with calling convention 'x86_64_sysv'
16// :5:30: note: arrays are not allowed as a return type15// :5:30: note: arrays are not allowed as a return type
test/cases/compile_errors/assign_inline_fn_to_non-comptime_var.zig+1-1
...@@ -8,5 +8,5 @@ inline fn b() void {}...@@ -8,5 +8,5 @@ inline fn b() void {}
8// backend=stage28// backend=stage2
9// target=native9// target=native
10//10//
11// :2:9: error: variable of type '*const fn () callconv(.Inline) void' must be const or comptime11// :2:9: error: variable of type '*const fn () callconv(.@"inline") void' must be const or comptime
12// :2:9: note: function has inline calling convention12// :2:9: note: function has inline calling convention
test/cases/compile_errors/bitsize_of_packed_struct_checks_backing_int_ty.zig+1-1
...@@ -1,7 +1,7 @@...@@ -1,7 +1,7 @@
1const Foo = packed struct(u32) {1const Foo = packed struct(u32) {
2 x: u1,2 x: u1,
3};3};
4fn bar(_: Foo) callconv(.C) void {}4fn bar(_: Foo) callconv(.c) void {}
5pub export fn entry() void {5pub export fn entry() void {
6 bar(.{ .x = 0 });6 bar(.{ .x = 0 });
7}7}
test/cases/compile_errors/callconv_apcs_aapcs_aapcsvfp_on_unsupported_platform.zig+3-4
...@@ -3,9 +3,8 @@ export fn entry2() callconv(.AAPCS) void {}...@@ -3,9 +3,8 @@ export fn entry2() callconv(.AAPCS) void {}
3export fn entry3() callconv(.AAPCSVFP) void {}3export fn entry3() callconv(.AAPCSVFP) void {}
44
5// error5// error
6// backend=stage2
7// target=x86_64-linux-none6// target=x86_64-linux-none
8//7//
9// :1:30: error: callconv 'APCS' is only available on ARM, not x86_648// :1:30: error: callconv 'arm_apcs' only available on architectures 'arm', 'armeb', 'thumb', 'thumbeb'
10// :2:30: error: callconv 'AAPCS' is only available on ARM, not x86_649// :2:30: error: callconv 'arm_aapcs' only available on architectures 'arm', 'armeb', 'thumb', 'thumbeb'
11// :3:30: error: callconv 'AAPCSVFP' is only available on ARM, not x86_6410// :3:30: error: callconv 'arm_aapcs_vfp' only available on architectures 'arm', 'armeb', 'thumb', 'thumbeb'
test/cases/compile_errors/callconv_signal_on_unsupported_platform.zig+2-2
...@@ -1,7 +1,7 @@...@@ -1,7 +1,7 @@
1export fn entry() callconv(.Signal) void {}1export fn entry() callconv(.avr_signal) void {}
22
3// error3// error
4// backend=stage24// backend=stage2
5// target=x86_64-linux-none5// target=x86_64-linux-none
6//6//
7// :1:29: error: callconv 'Signal' is only available on AVR, not x86_647// :1:29: error: callconv 'avr_signal' only available on architectures 'avr'
test/cases/compile_errors/callconv_stdcall_fastcall_thiscall_on_unsupported_platform.zig+6-6
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1const F1 = fn () callconv(.Stdcall) void;1const F1 = fn () callconv(.{ .x86_stdcall = .{} }) void;
2const F2 = fn () callconv(.Fastcall) void;2const F2 = fn () callconv(.{ .x86_fastcall = .{} }) void;
3const F3 = fn () callconv(.Thiscall) void;3const F3 = fn () callconv(.{ .x86_thiscall = .{} }) void;
4export fn entry1() void {4export fn entry1() void {
5 const a: F1 = undefined;5 const a: F1 = undefined;
6 _ = a;6 _ = a;
...@@ -18,6 +18,6 @@ export fn entry3() void {...@@ -18,6 +18,6 @@ export fn entry3() void {
18// backend=stage218// backend=stage2
19// target=x86_64-linux-none19// target=x86_64-linux-none
20//20//
21// :1:28: error: callconv 'Stdcall' is only available on x86, not x86_6421// :1:28: error: callconv 'x86_stdcall' only available on architectures 'x86'
22// :2:28: error: callconv 'Fastcall' is only available on x86, not x86_6422// :2:28: error: callconv 'x86_fastcall' only available on architectures 'x86'
23// :3:28: error: callconv 'Thiscall' is only available on x86, not x86_6423// :3:28: error: callconv 'x86_thiscall' only available on architectures 'x86'
test/cases/compile_errors/callconv_vectorcall_on_unsupported_platform.zig deleted-7
...@@ -1,7 +0,0 @@
1export fn entry() callconv(.Vectorcall) void {}
2
3// error
4// backend=stage2
5// target=x86_64-linux-none
6//
7// :1:29: error: callconv 'Vectorcall' is only available on x86 and AArch64, not x86_64
test/cases/compile_errors/closure_get_depends_on_failed_decl.zig+1-1
...@@ -4,7 +4,7 @@ pub inline fn requestAdapter(...@@ -4,7 +4,7 @@ pub inline fn requestAdapter(
4 comptime callbackArg: fn () callconv(.Inline) void,4 comptime callbackArg: fn () callconv(.Inline) void,
5) void {5) void {
6 _ = &(struct {6 _ = &(struct {
7 pub fn callback() callconv(.C) void {7 pub fn callback() callconv(.c) void {
8 callbackArg();8 callbackArg();
9 }9 }
10 }).callback;10 }).callback;
test/cases/compile_errors/export_function_with_comptime_parameter.zig+2-3
...@@ -3,7 +3,6 @@ export fn foo(comptime x: anytype, y: i32) i32 {...@@ -3,7 +3,6 @@ export fn foo(comptime x: anytype, y: i32) i32 {
3}3}
44
5// error5// error
6// backend=stage26// target=x86_64-linux
7// target=native
8//7//
9// :1:15: error: comptime parameters not allowed in function with calling convention 'C'8// :1:15: error: comptime parameters not allowed in function with calling convention 'x86_64_sysv'
test/cases/compile_errors/export_generic_function.zig+2-3
...@@ -4,7 +4,6 @@ export fn foo(num: anytype) i32 {...@@ -4,7 +4,6 @@ export fn foo(num: anytype) i32 {
4}4}
55
6// error6// error
7// backend=stage27// target=x86_64-linux
8// target=native
9//8//
10// :1:15: error: generic parameters not allowed in function with calling convention 'C'9// :1:15: error: generic parameters not allowed in function with calling convention 'x86_64_sysv'
test/cases/compile_errors/extern_function_pointer_mismatch.zig+3-4
...@@ -14,8 +14,7 @@ export fn entry() usize {...@@ -14,8 +14,7 @@ export fn entry() usize {
14}14}
1515
16// error16// error
17// backend=stage217// target=x86_64-linux
18// target=native
19//18//
20// :1:38: error: expected type 'fn (i32) i32', found 'fn (i32) callconv(.C) i32'19// :1:38: error: expected type 'fn (i32) i32', found 'fn (i32) callconv(.c) i32'
21// :1:38: note: calling convention 'C' cannot cast into calling convention 'Unspecified'20// :1:38: note: calling convention 'x86_64_sysv' cannot cast into calling convention 'auto'
test/cases/compile_errors/extern_function_with_comptime_parameter.zig+4-5
...@@ -15,9 +15,8 @@ comptime {...@@ -15,9 +15,8 @@ comptime {
15}15}
1616
17// error17// error
18// backend=stage218// target=x86_64-linux
19// target=native
20//19//
21// :1:15: error: comptime parameters not allowed in function with calling convention 'C'20// :1:15: error: comptime parameters not allowed in function with calling convention 'x86_64_sysv'
22// :5:30: error: comptime parameters not allowed in function with calling convention 'C'21// :5:30: error: comptime parameters not allowed in function with calling convention 'x86_64_sysv'
23// :6:30: error: generic parameters not allowed in function with calling convention 'C'22// :6:30: error: generic parameters not allowed in function with calling convention 'x86_64_sysv'
test/cases/compile_errors/function-only_builtins_outside_function.zig+12-17
...@@ -1,7 +1,3 @@...@@ -1,7 +1,3 @@
1comptime {
2 @setAlignStack(1);
3}
4
5comptime {1comptime {
6 @branchHint(.cold);2 @branchHint(.cold);
7}3}
...@@ -54,16 +50,15 @@ comptime {...@@ -54,16 +50,15 @@ comptime {
54// backend=stage250// backend=stage2
55// target=native51// target=native
56//52//
57// :2:5: error: '@setAlignStack' outside function scope53// :2:5: error: '@branchHint' outside function scope
58// :6:5: error: '@branchHint' outside function scope54// :6:5: error: '@src' outside function scope
59// :10:5: error: '@src' outside function scope55// :10:5: error: '@returnAddress' outside function scope
60// :14:5: error: '@returnAddress' outside function scope56// :14:5: error: '@frameAddress' outside function scope
61// :18:5: error: '@frameAddress' outside function scope57// :18:5: error: '@breakpoint' outside function scope
62// :22:5: error: '@breakpoint' outside function scope58// :22:5: error: '@cVaArg' outside function scope
63// :26:5: error: '@cVaArg' outside function scope59// :26:5: error: '@cVaCopy' outside function scope
64// :30:5: error: '@cVaCopy' outside function scope60// :30:5: error: '@cVaEnd' outside function scope
65// :34:5: error: '@cVaEnd' outside function scope61// :34:5: error: '@cVaStart' outside function scope
66// :38:5: error: '@cVaStart' outside function scope62// :38:5: error: '@workItemId' outside function scope
67// :42:5: error: '@workItemId' outside function scope63// :42:5: error: '@workGroupSize' outside function scope
68// :46:5: error: '@workGroupSize' outside function scope64// :46:5: error: '@workGroupId' outside function scope
69// :50:5: error: '@workGroupId' outside function scope
test/cases/compile_errors/function_with_non-extern_non-packed_enum_parameter.zig+2-3
...@@ -4,10 +4,9 @@ export fn entry(foo: Foo) void {...@@ -4,10 +4,9 @@ export fn entry(foo: Foo) void {
4}4}
55
6// error6// error
7// backend=stage27// target=x86_64-linux
8// target=native
9//8//
10// :2:17: error: parameter of type 'tmp.Foo' not allowed in function with calling convention 'C'9// :2:17: error: parameter of type 'tmp.Foo' not allowed in function with calling convention 'x86_64_sysv'
11// :2:17: note: enum tag type 'u2' is not extern compatible10// :2:17: note: enum tag type 'u2' is not extern compatible
12// :2:17: note: only integers with 0, 8, 16, 32, 64 and 128 bits are extern compatible11// :2:17: note: only integers with 0, 8, 16, 32, 64 and 128 bits are extern compatible
13// :1:13: note: enum declared here12// :1:13: note: enum declared here
test/cases/compile_errors/function_with_non-extern_non-packed_struct_parameter.zig+2-3
...@@ -8,9 +8,8 @@ export fn entry(foo: Foo) void {...@@ -8,9 +8,8 @@ export fn entry(foo: Foo) void {
8}8}
99
10// error10// error
11// backend=stage211// target=x86_64-linux
12// target=native
13//12//
14// :6:17: error: parameter of type 'tmp.Foo' not allowed in function with calling convention 'C'13// :6:17: error: parameter of type 'tmp.Foo' not allowed in function with calling convention 'x86_64_sysv'
15// :6:17: note: only extern structs and ABI sized packed structs are extern compatible14// :6:17: note: only extern structs and ABI sized packed structs are extern compatible
16// :1:13: note: struct declared here15// :1:13: note: struct declared here
test/cases/compile_errors/function_with_non-extern_non-packed_union_parameter.zig+2-3
...@@ -8,9 +8,8 @@ export fn entry(foo: Foo) void {...@@ -8,9 +8,8 @@ export fn entry(foo: Foo) void {
8}8}
99
10// error10// error
11// backend=stage211// target=x86_64-linux
12// target=native
13//12//
14// :6:17: error: parameter of type 'tmp.Foo' not allowed in function with calling convention 'C'13// :6:17: error: parameter of type 'tmp.Foo' not allowed in function with calling convention 'x86_64_sysv'
15// :6:17: note: only extern unions and ABI sized packed unions are extern compatible14// :6:17: note: only extern unions and ABI sized packed unions are extern compatible
16// :1:13: note: union declared here15// :1:13: note: union declared here
test/cases/compile_errors/invalid_extern_function_call.zig+1-1
...@@ -1,4 +1,4 @@...@@ -1,4 +1,4 @@
1const x = @extern(*const fn () callconv(.C) void, .{ .name = "foo" });1const x = @extern(*const fn () callconv(.c) void, .{ .name = "foo" });
22
3export fn entry0() void {3export fn entry0() void {
4 comptime x();4 comptime x();
test/cases/compile_errors/invalid_func_for_callconv.zig+7-8
...@@ -9,12 +9,11 @@ export fn signal_param(_: u32) callconv(.Signal) void {}...@@ -9,12 +9,11 @@ export fn signal_param(_: u32) callconv(.Signal) void {}
9export fn signal_ret() callconv(.Signal) noreturn {}9export fn signal_ret() callconv(.Signal) noreturn {}
1010
11// error11// error
12// backend=stage2
13// target=x86_64-linux12// target=x86_64-linux
14// 13//
15// :1:28: error: first parameter of function with 'Interrupt' calling convention must be a pointer type14// :1:28: error: first parameter of function with 'x86_64_interrupt' calling convention must be a pointer type
16// :2:43: error: second parameter of function with 'Interrupt' calling convention must be a 64-bit integer15// :2:43: error: second parameter of function with 'x86_64_interrupt' calling convention must be a 64-bit integer
17// :3:51: error: 'Interrupt' calling convention supports up to 2 parameters, found 316// :3:51: error: 'x86_64_interrupt' calling convention supports up to 2 parameters, found 3
18// :4:69: error: function with calling convention 'Interrupt' must return 'void' or 'noreturn'17// :4:69: error: function with calling convention 'x86_64_interrupt' must return 'void' or 'noreturn'
19// :8:24: error: parameters are not allowed with 'Signal' calling convention18// :8:24: error: parameters are not allowed with 'avr_signal' calling convention
20// :9:34: error: callconv 'Signal' is only available on AVR, not x86_6419// :9:34: error: callconv 'avr_signal' only available on architectures 'avr'
test/cases/compile_errors/invalid_tail_call.zig+1-1
...@@ -9,4 +9,4 @@ pub export fn entry() void {...@@ -9,4 +9,4 @@ pub export fn entry() void {
9// backend=llvm9// backend=llvm
10// target=native10// target=native
11//11//
12// :5:5: error: unable to perform tail call: type of function being called 'fn (usize) void' does not match type of calling function 'fn () callconv(.C) void'12// :5:5: error: unable to perform tail call: type of function being called 'fn (usize) void' does not match type of calling function 'fn () callconv(.c) void'
test/cases/compile_errors/invalid_variadic_function.zig+5-6
...@@ -13,11 +13,10 @@ comptime {...@@ -13,11 +13,10 @@ comptime {
13}13}
1414
15// error15// error
16// backend=stage216// target=x86_64-linux
17// target=native
18//17//
19// :1:1: error: variadic function does not support '.Unspecified' calling convention18// :1:1: error: variadic function does not support 'auto' calling convention
20// :1:1: note: supported calling conventions: '.C'19// :1:1: note: supported calling conventions: 'x86_64_sysv', 'x86_64_win'
21// :1:1: error: variadic function does not support '.Inline' calling convention20// :1:1: error: variadic function does not support 'inline' calling convention
22// :1:1: note: supported calling conventions: '.C'21// :1:1: note: supported calling conventions: 'x86_64_sysv', 'x86_64_win'
23// :2:1: error: generic function cannot be variadic22// :2:1: error: generic function cannot be variadic
test/cases/compile_errors/noinline_fn_cc_inline.zig+2-3
...@@ -1,5 +1,4 @@...@@ -1,5 +1,4 @@
1const cc = .Inline;1noinline fn foo() callconv(.@"inline") void {}
2noinline fn foo() callconv(cc) void {}
32
4comptime {3comptime {
5 _ = foo;4 _ = foo;
...@@ -9,4 +8,4 @@ comptime {...@@ -9,4 +8,4 @@ comptime {
9// backend=stage28// backend=stage2
10// target=native9// target=native
11//10//
12// :2:28: error: 'noinline' function cannot have callconv 'Inline'11// :1:29: error: 'noinline' function cannot have callconv 'inline'
test/cases/compile_errors/old_fn_ptr_in_extern_context.zig+4-4
...@@ -1,20 +1,20 @@...@@ -1,20 +1,20 @@
1const S = extern struct {1const S = extern struct {
2 a: fn () callconv(.C) void,2 a: fn () callconv(.c) void,
3};3};
4comptime {4comptime {
5 _ = @sizeOf(S) == 1;5 _ = @sizeOf(S) == 1;
6}6}
7comptime {7comptime {
8 _ = [*c][4]fn () callconv(.C) void;8 _ = [*c][4]fn () callconv(.c) void;
9}9}
1010
11// error11// error
12// backend=stage212// backend=stage2
13// target=native13// target=native
14//14//
15// :2:8: error: extern structs cannot contain fields of type 'fn () callconv(.C) void'15// :2:8: error: extern structs cannot contain fields of type 'fn () callconv(.c) void'
16// :2:8: note: type has no guaranteed in-memory representation16// :2:8: note: type has no guaranteed in-memory representation
17// :2:8: note: use '*const ' to make a function pointer type17// :2:8: note: use '*const ' to make a function pointer type
18// :8:13: error: C pointers cannot point to non-C-ABI-compatible type '[4]fn () callconv(.C) void'18// :8:13: error: C pointers cannot point to non-C-ABI-compatible type '[4]fn () callconv(.c) void'
19// :8:13: note: type has no guaranteed in-memory representation19// :8:13: note: type has no guaranteed in-memory representation
20// :8:13: note: use '*const ' to make a function pointer type20// :8:13: note: use '*const ' to make a function pointer type
test/cases/compile_errors/reify_type.Fn_with_is_var_args_true_and_non-C_callconv.zig+3-4
...@@ -12,8 +12,7 @@ comptime {...@@ -12,8 +12,7 @@ comptime {
12}12}
1313
14// error14// error
15// backend=stage215// target=x86_64-linux
16// target=native
17//16//
18// :1:13: error: variadic function does not support '.Unspecified' calling convention17// :1:13: error: variadic function does not support 'auto' calling convention
19// :1:13: note: supported calling conventions: '.C'18// :1:13: note: supported calling conventions: 'x86_64_sysv', 'x86_64_win'
test/cases/compile_errors/runtime_@ptrFromInt_to_comptime_only_type.zig+2-2
...@@ -1,5 +1,5 @@...@@ -1,5 +1,5 @@
1const GuSettings = struct {1const GuSettings = struct {
2 fin: ?fn (c_int) callconv(.C) void,2 fin: ?fn (c_int) callconv(.c) void,
3};3};
4pub export fn callbackFin(id: c_int, arg: ?*anyopaque) void {4pub export fn callbackFin(id: c_int, arg: ?*anyopaque) void {
5 const settings: ?*GuSettings = @as(?*GuSettings, @ptrFromInt(@intFromPtr(arg)));5 const settings: ?*GuSettings = @as(?*GuSettings, @ptrFromInt(@intFromPtr(arg)));
...@@ -13,4 +13,4 @@ pub export fn callbackFin(id: c_int, arg: ?*anyopaque) void {...@@ -13,4 +13,4 @@ pub export fn callbackFin(id: c_int, arg: ?*anyopaque) void {
13//13//
14// :5:54: error: pointer to comptime-only type '?*tmp.GuSettings' must be comptime-known, but operand is runtime-known14// :5:54: error: pointer to comptime-only type '?*tmp.GuSettings' must be comptime-known, but operand is runtime-known
15// :2:10: note: struct requires comptime because of this field15// :2:10: note: struct requires comptime because of this field
16// :2:10: note: use '*const fn (c_int) callconv(.C) void' for a function pointer type16// :2:10: note: use '*const fn (c_int) callconv(.c) void' for a function pointer type
test/cases/compile_errors/setAlignStack_in_naked_function.zig deleted-9
...@@ -1,9 +0,0 @@
1export fn entry() callconv(.Naked) void {
2 @setAlignStack(16);
3}
4
5// error
6// backend=stage2
7// target=native
8//
9// :2:5: error: @setAlignStack in naked function
test/cases/compile_errors/setAlignStack_too_big.zig deleted-9
...@@ -1,9 +0,0 @@
1export fn entry() void {
2 @setAlignStack(511 + 1);
3}
4
5// error
6// backend=stage2
7// target=native
8//
9// :2:5: error: attempt to @setAlignStack(512); maximum is 256
test/cases/compile_errors/slice_used_as_extern_fn_param.zig+3-4
...@@ -1,11 +1,10 @@...@@ -1,11 +1,10 @@
1extern fn Text(str: []const u8, num: i32) callconv(.C) void;1extern fn Text(str: []const u8, num: i32) callconv(.c) void;
2export fn entry() void {2export fn entry() void {
3 _ = Text;3 _ = Text;
4}4}
55
6// error6// error
7// backend=stage27// target=x86_64-linux
8// target=native
9//8//
10// :1:16: error: parameter of type '[]const u8' not allowed in function with calling convention 'C'9// :1:16: error: parameter of type '[]const u8' not allowed in function with calling convention 'x86_64_sysv'
11// :1:16: note: slices have no guaranteed in-memory representation10// :1:16: note: slices have no guaranteed in-memory representation
test/cases/compile_errors/type_mismatch_in_C_prototype_with_varargs.zig+2-2
...@@ -1,4 +1,4 @@...@@ -1,4 +1,4 @@
1const fn_ty = ?fn ([*c]u8, ...) callconv(.C) void;1const fn_ty = ?fn ([*c]u8, ...) callconv(.c) void;
2extern fn fn_decl(fmt: [*:0]u8, ...) void;2extern fn fn_decl(fmt: [*:0]u8, ...) void;
33
4export fn main() void {4export fn main() void {
...@@ -10,6 +10,6 @@ export fn main() void {...@@ -10,6 +10,6 @@ export fn main() void {
10// backend=stage210// backend=stage2
11// target=native11// target=native
12//12//
13// :5:22: error: expected type '?fn ([*c]u8, ...) callconv(.C) void', found 'fn ([*:0]u8, ...) callconv(.C) void'13// :5:22: error: expected type '?fn ([*c]u8, ...) callconv(.c) void', found 'fn ([*:0]u8, ...) callconv(.c) void'
14// :5:22: note: parameter 0 '[*:0]u8' cannot cast into '[*c]u8'14// :5:22: note: parameter 0 '[*:0]u8' cannot cast into '[*c]u8'
15// :5:22: note: '[*c]u8' could have null values which are illegal in type '[*:0]u8'15// :5:22: note: '[*c]u8' could have null values which are illegal in type '[*:0]u8'
test/cases/compile_errors/wrong_types_given_to_export.zig+1-1
...@@ -1,4 +1,4 @@...@@ -1,4 +1,4 @@
1fn entry() callconv(.C) void {}1fn entry() callconv(.c) void {}
2comptime {2comptime {
3 @export(&entry, .{ .name = "entry", .linkage = @as(u32, 1234) });3 @export(&entry, .{ .name = "entry", .linkage = @as(u32, 1234) });
4}4}
test/cases/translate_c/static empty struct.c +1-1
...@@ -9,7 +9,7 @@ static inline void foo() {...@@ -9,7 +9,7 @@ static inline void foo() {
9// c_frontend=clang9// c_frontend=clang
10//10//
11// pub const struct_empty_struct = extern struct {};11// pub const struct_empty_struct = extern struct {};
12// pub fn foo() callconv(.C) void {12// pub fn foo() callconv(.c) void {
13// const bar = struct {13// const bar = struct {
14// var static: struct_empty_struct = @import("std").mem.zeroes(struct_empty_struct);14// var static: struct_empty_struct = @import("std").mem.zeroes(struct_empty_struct);
15// };15// };
test/translate_c.zig+34-34
...@@ -484,11 +484,11 @@ pub fn addCases(cases: *tests.TranslateCContext) void {...@@ -484,11 +484,11 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
484 \\ fnptr_attr_ty qux;484 \\ fnptr_attr_ty qux;
485 \\};485 \\};
486 , &[_][]const u8{486 , &[_][]const u8{
487 \\pub const fnptr_ty = ?*const fn () callconv(.C) void;487 \\pub const fnptr_ty = ?*const fn () callconv(.c) void;
488 \\pub const fnptr_attr_ty = ?*const fn () callconv(.C) void;488 \\pub const fnptr_attr_ty = ?*const fn () callconv(.c) void;
489 \\pub const struct_foo = extern struct {489 \\pub const struct_foo = extern struct {
490 \\ foo: ?*const fn () callconv(.C) void = @import("std").mem.zeroes(?*const fn () callconv(.C) void),490 \\ foo: ?*const fn () callconv(.c) void = @import("std").mem.zeroes(?*const fn () callconv(.c) void),
491 \\ bar: ?*const fn () callconv(.C) void = @import("std").mem.zeroes(?*const fn () callconv(.C) void),491 \\ bar: ?*const fn () callconv(.c) void = @import("std").mem.zeroes(?*const fn () callconv(.c) void),
492 \\ baz: fnptr_ty = @import("std").mem.zeroes(fnptr_ty),492 \\ baz: fnptr_ty = @import("std").mem.zeroes(fnptr_ty),
493 \\ qux: fnptr_attr_ty = @import("std").mem.zeroes(fnptr_attr_ty),493 \\ qux: fnptr_attr_ty = @import("std").mem.zeroes(fnptr_attr_ty),
494 \\};494 \\};
...@@ -735,7 +735,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {...@@ -735,7 +735,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
735 \\static void bar(void) {}735 \\static void bar(void) {}
736 , &[_][]const u8{736 , &[_][]const u8{
737 \\pub export fn foo() void {}737 \\pub export fn foo() void {}
738 \\pub fn bar() callconv(.C) void {}738 \\pub fn bar() callconv(.c) void {}
739 });739 });
740740
741 cases.add("typedef void",741 cases.add("typedef void",
...@@ -769,7 +769,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {...@@ -769,7 +769,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
769 \\pub export fn bar() void {769 \\pub export fn bar() void {
770 \\ var func_ptr: ?*anyopaque = @as(?*anyopaque, @ptrCast(&foo));770 \\ var func_ptr: ?*anyopaque = @as(?*anyopaque, @ptrCast(&foo));
771 \\ _ = &func_ptr;771 \\ _ = &func_ptr;
772 \\ var typed_func_ptr: ?*const fn () callconv(.C) void = @as(?*const fn () callconv(.C) void, @ptrFromInt(@as(c_ulong, @intCast(@intFromPtr(func_ptr)))));772 \\ var typed_func_ptr: ?*const fn () callconv(.c) void = @as(?*const fn () callconv(.c) void, @ptrFromInt(@as(c_ulong, @intCast(@intFromPtr(func_ptr)))));
773 \\ _ = &typed_func_ptr;773 \\ _ = &typed_func_ptr;
774 \\}774 \\}
775 });775 });
...@@ -839,9 +839,9 @@ pub fn addCases(cases: *tests.TranslateCContext) void {...@@ -839,9 +839,9 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
839 \\ lws_callback_function *callback_http;839 \\ lws_callback_function *callback_http;
840 \\};840 \\};
841 , &[_][]const u8{841 , &[_][]const u8{
842 \\pub const lws_callback_function = fn () callconv(.C) void;842 \\pub const lws_callback_function = fn () callconv(.c) void;
843 \\pub const struct_Foo = extern struct {843 \\pub const struct_Foo = extern struct {
844 \\ func: ?*const fn () callconv(.C) void = @import("std").mem.zeroes(?*const fn () callconv(.C) void),844 \\ func: ?*const fn () callconv(.c) void = @import("std").mem.zeroes(?*const fn () callconv(.c) void),
845 \\ callback_http: ?*const lws_callback_function = @import("std").mem.zeroes(?*const lws_callback_function),845 \\ callback_http: ?*const lws_callback_function = @import("std").mem.zeroes(?*const lws_callback_function),
846 \\};846 \\};
847 });847 });
...@@ -867,7 +867,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {...@@ -867,7 +867,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
867 \\};867 \\};
868 , &[_][]const u8{868 , &[_][]const u8{
869 \\pub const struct_Foo = extern struct {869 \\pub const struct_Foo = extern struct {
870 \\ derp: ?*const fn ([*c]struct_Foo) callconv(.C) void = @import("std").mem.zeroes(?*const fn ([*c]struct_Foo) callconv(.C) void),870 \\ derp: ?*const fn ([*c]struct_Foo) callconv(.c) void = @import("std").mem.zeroes(?*const fn ([*c]struct_Foo) callconv(.c) void),
871 \\};871 \\};
872 ,872 ,
873 \\pub const Foo = struct_Foo;873 \\pub const Foo = struct_Foo;
...@@ -1111,7 +1111,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {...@@ -1111,7 +1111,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
1111 cases.add("__cdecl doesn't mess up function pointers",1111 cases.add("__cdecl doesn't mess up function pointers",
1112 \\void foo(void (__cdecl *fn_ptr)(void));1112 \\void foo(void (__cdecl *fn_ptr)(void));
1113 , &[_][]const u8{1113 , &[_][]const u8{
1114 \\pub extern fn foo(fn_ptr: ?*const fn () callconv(.C) void) void;1114 \\pub extern fn foo(fn_ptr: ?*const fn () callconv(.c) void) void;
1115 });1115 });
11161116
1117 cases.add("void cast",1117 cases.add("void cast",
...@@ -1477,8 +1477,8 @@ pub fn addCases(cases: *tests.TranslateCContext) void {...@@ -1477,8 +1477,8 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
1477 \\typedef void (*fn0)();1477 \\typedef void (*fn0)();
1478 \\typedef void (*fn1)(char);1478 \\typedef void (*fn1)(char);
1479 , &[_][]const u8{1479 , &[_][]const u8{
1480 \\pub const fn0 = ?*const fn (...) callconv(.C) void;1480 \\pub const fn0 = ?*const fn (...) callconv(.c) void;
1481 \\pub const fn1 = ?*const fn (u8) callconv(.C) void;1481 \\pub const fn1 = ?*const fn (u8) callconv(.c) void;
1482 });1482 });
14831483
1484 cases.addWithTarget("Calling convention", .{1484 cases.addWithTarget("Calling convention", .{
...@@ -1492,11 +1492,11 @@ pub fn addCases(cases: *tests.TranslateCContext) void {...@@ -1492,11 +1492,11 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
1492 \\void __attribute__((cdecl)) foo4(float *a);1492 \\void __attribute__((cdecl)) foo4(float *a);
1493 \\void __attribute__((thiscall)) foo5(float *a);1493 \\void __attribute__((thiscall)) foo5(float *a);
1494 , &[_][]const u8{1494 , &[_][]const u8{
1495 \\pub extern fn foo1(a: [*c]f32) callconv(.Fastcall) void;1495 \\pub extern fn foo1(a: [*c]f32) callconv(.{ .x86_fastcall = .{} }) void;
1496 \\pub extern fn foo2(a: [*c]f32) callconv(.Stdcall) void;1496 \\pub extern fn foo2(a: [*c]f32) callconv(.{ .x86_stdcall = .{} }) void;
1497 \\pub extern fn foo3(a: [*c]f32) callconv(.Vectorcall) void;1497 \\pub extern fn foo3(a: [*c]f32) callconv(.{ .x86_vectorcall = .{} }) void;
1498 \\pub extern fn foo4(a: [*c]f32) void;1498 \\pub extern fn foo4(a: [*c]f32) void;
1499 \\pub extern fn foo5(a: [*c]f32) callconv(.Thiscall) void;1499 \\pub extern fn foo5(a: [*c]f32) callconv(.{ .x86_thiscall = .{} }) void;
1500 });1500 });
15011501
1502 cases.addWithTarget("Calling convention", std.Target.Query.parse(.{1502 cases.addWithTarget("Calling convention", std.Target.Query.parse(.{
...@@ -1506,8 +1506,8 @@ pub fn addCases(cases: *tests.TranslateCContext) void {...@@ -1506,8 +1506,8 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
1506 \\void __attribute__((pcs("aapcs"))) foo1(float *a);1506 \\void __attribute__((pcs("aapcs"))) foo1(float *a);
1507 \\void __attribute__((pcs("aapcs-vfp"))) foo2(float *a);1507 \\void __attribute__((pcs("aapcs-vfp"))) foo2(float *a);
1508 , &[_][]const u8{1508 , &[_][]const u8{
1509 \\pub extern fn foo1(a: [*c]f32) callconv(.AAPCS) void;1509 \\pub extern fn foo1(a: [*c]f32) callconv(.{ .arm_aapcs = .{} }) void;
1510 \\pub extern fn foo2(a: [*c]f32) callconv(.AAPCSVFP) void;1510 \\pub extern fn foo2(a: [*c]f32) callconv(.{ .arm_aapcs_vfp = .{} }) void;
1511 });1511 });
15121512
1513 cases.addWithTarget("Calling convention", std.Target.Query.parse(.{1513 cases.addWithTarget("Calling convention", std.Target.Query.parse(.{
...@@ -1516,7 +1516,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {...@@ -1516,7 +1516,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
1516 }) catch unreachable,1516 }) catch unreachable,
1517 \\void __attribute__((aarch64_vector_pcs)) foo1(float *a);1517 \\void __attribute__((aarch64_vector_pcs)) foo1(float *a);
1518 , &[_][]const u8{1518 , &[_][]const u8{
1519 \\pub extern fn foo1(a: [*c]f32) callconv(.Vectorcall) void;1519 \\pub extern fn foo1(a: [*c]f32) callconv(.{ .aarch64_vfabi = .{} }) void;
1520 });1520 });
15211521
1522 cases.add("Parameterless function prototypes",1522 cases.add("Parameterless function prototypes",
...@@ -1533,8 +1533,8 @@ pub fn addCases(cases: *tests.TranslateCContext) void {...@@ -1533,8 +1533,8 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
1533 \\pub export fn b() void {}1533 \\pub export fn b() void {}
1534 \\pub extern fn c(...) void;1534 \\pub extern fn c(...) void;
1535 \\pub extern fn d() void;1535 \\pub extern fn d() void;
1536 \\pub fn e() callconv(.C) void {}1536 \\pub fn e() callconv(.c) void {}
1537 \\pub fn f() callconv(.C) void {}1537 \\pub fn f() callconv(.c) void {}
1538 \\pub extern fn g() void;1538 \\pub extern fn g() void;
1539 \\pub extern fn h() void;1539 \\pub extern fn h() void;
1540 });1540 });
...@@ -1555,7 +1555,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {...@@ -1555,7 +1555,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
1555 \\ char *arr1[10] ={0};1555 \\ char *arr1[10] ={0};
1556 \\}1556 \\}
1557 , &[_][]const u8{1557 , &[_][]const u8{
1558 \\pub fn foo() callconv(.C) void {1558 \\pub fn foo() callconv(.c) void {
1559 \\ var arr: [10]u8 = [1]u8{1559 \\ var arr: [10]u8 = [1]u8{
1560 \\ 1,1560 \\ 1,
1561 \\ } ++ [1]u8{0} ** 9;1561 \\ } ++ [1]u8{0} ** 9;
...@@ -1686,13 +1686,13 @@ pub fn addCases(cases: *tests.TranslateCContext) void {...@@ -1686,13 +1686,13 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
1686 \\extern char (*fn_ptr2)(int, float);1686 \\extern char (*fn_ptr2)(int, float);
1687 \\#define bar fn_ptr21687 \\#define bar fn_ptr2
1688 , &[_][]const u8{1688 , &[_][]const u8{
1689 \\pub extern var fn_ptr: ?*const fn () callconv(.C) void;1689 \\pub extern var fn_ptr: ?*const fn () callconv(.c) void;
1690 ,1690 ,
1691 \\pub inline fn foo() void {1691 \\pub inline fn foo() void {
1692 \\ return fn_ptr.?();1692 \\ return fn_ptr.?();
1693 \\}1693 \\}
1694 ,1694 ,
1695 \\pub extern var fn_ptr2: ?*const fn (c_int, f32) callconv(.C) u8;1695 \\pub extern var fn_ptr2: ?*const fn (c_int, f32) callconv(.c) u8;
1696 ,1696 ,
1697 \\pub inline fn bar(arg_1: c_int, arg_2: f32) u8 {1697 \\pub inline fn bar(arg_1: c_int, arg_2: f32) u8 {
1698 \\ return fn_ptr2.?(arg_1, arg_2);1698 \\ return fn_ptr2.?(arg_1, arg_2);
...@@ -1714,8 +1714,8 @@ pub fn addCases(cases: *tests.TranslateCContext) void {...@@ -1714,8 +1714,8 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
1714 \\#define glClearPFN PFNGLCLEARPROC1714 \\#define glClearPFN PFNGLCLEARPROC
1715 , &[_][]const u8{1715 , &[_][]const u8{
1716 \\pub const GLbitfield = c_uint;1716 \\pub const GLbitfield = c_uint;
1717 \\pub const PFNGLCLEARPROC = ?*const fn (GLbitfield) callconv(.C) void;1717 \\pub const PFNGLCLEARPROC = ?*const fn (GLbitfield) callconv(.c) void;
1718 \\pub const OpenGLProc = ?*const fn () callconv(.C) void;1718 \\pub const OpenGLProc = ?*const fn () callconv(.c) void;
1719 \\const struct_unnamed_1 = extern struct {1719 \\const struct_unnamed_1 = extern struct {
1720 \\ Clear: PFNGLCLEARPROC = @import("std").mem.zeroes(PFNGLCLEARPROC),1720 \\ Clear: PFNGLCLEARPROC = @import("std").mem.zeroes(PFNGLCLEARPROC),
1721 \\};1721 \\};
...@@ -2691,9 +2691,9 @@ pub fn addCases(cases: *tests.TranslateCContext) void {...@@ -2691,9 +2691,9 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
2691 \\ return 0;2691 \\ return 0;
2692 \\}2692 \\}
2693 \\pub export fn bar() void {2693 \\pub export fn bar() void {
2694 \\ var f: ?*const fn () callconv(.C) void = &foo;2694 \\ var f: ?*const fn () callconv(.c) void = &foo;
2695 \\ _ = &f;2695 \\ _ = &f;
2696 \\ var b: ?*const fn () callconv(.C) c_int = &baz;2696 \\ var b: ?*const fn () callconv(.c) c_int = &baz;
2697 \\ _ = &b;2697 \\ _ = &b;
2698 \\ f.?();2698 \\ f.?();
2699 \\ f.?();2699 \\ f.?();
...@@ -3048,8 +3048,8 @@ pub fn addCases(cases: *tests.TranslateCContext) void {...@@ -3048,8 +3048,8 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
3048 \\ baz();3048 \\ baz();
3049 \\}3049 \\}
3050 , &[_][]const u8{3050 , &[_][]const u8{
3051 \\pub fn bar() callconv(.C) void {}3051 \\pub fn bar() callconv(.c) void {}
3052 \\pub export fn foo(arg_baz: ?*const fn () callconv(.C) [*c]c_int) void {3052 \\pub export fn foo(arg_baz: ?*const fn () callconv(.c) [*c]c_int) void {
3053 \\ var baz = arg_baz;3053 \\ var baz = arg_baz;
3054 \\ _ = &baz;3054 \\ _ = &baz;
3055 \\ bar();3055 \\ bar();
...@@ -3112,7 +3112,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {...@@ -3112,7 +3112,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
3112 \\ do {} while (0);3112 \\ do {} while (0);
3113 \\}3113 \\}
3114 , &[_][]const u8{3114 , &[_][]const u8{
3115 \\pub fn foo() callconv(.C) void {3115 \\pub fn foo() callconv(.c) void {
3116 \\ if (true) while (true) {3116 \\ if (true) while (true) {
3117 \\ if (!false) break;3117 \\ if (!false) break;
3118 \\ };3118 \\ };
...@@ -3212,10 +3212,10 @@ pub fn addCases(cases: *tests.TranslateCContext) void {...@@ -3212,10 +3212,10 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
3212 \\void c(void) {}3212 \\void c(void) {}
3213 \\static void foo() {}3213 \\static void foo() {}
3214 , &[_][]const u8{3214 , &[_][]const u8{
3215 \\pub fn a() callconv(.C) void {}3215 \\pub fn a() callconv(.c) void {}
3216 \\pub fn b() callconv(.C) void {}3216 \\pub fn b() callconv(.c) void {}
3217 \\pub export fn c() void {}3217 \\pub export fn c() void {}
3218 \\pub fn foo() callconv(.C) void {}3218 \\pub fn foo() callconv(.c) void {}
3219 });3219 });
32203220
3221 cases.add("casting away const and volatile",3221 cases.add("casting away const and volatile",