| author | |
| committer | |
| log | 4be0cf30fc10420c2b5fa97a3b25a07b7a0ce7f3 |
| tree | 0c239f9b68fbbc13ae94462756d466ef774a9772 |
| parent | ec19086aa0491024622c444b0d9310560de9e6f0 |
| signature |
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 | 1612 | |
| 1613 | 1613 | /// Returns the array of `Arch` to which a specific `std.builtin.CallingConvention` applies. |
| 1614 | 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 | 1616 | return switch (cc) { |
| 1617 | 1617 | .auto, |
| 1618 | 1618 | .@"async", |
lib/std/builtin.zig+5-3| ... | ... | @@ -173,7 +173,7 @@ pub const CallingConvention = union(enum(u8)) { |
| 173 | 173 | /// Functions marked as `extern` or `export` are given this calling convention by default. |
| 174 | 174 | pub const c = builtin.target.defaultCCallingConvention().?; |
| 175 | 175 | |
| 176 | pub const winapi: CallingConvention = switch (builtin.target.arch) { | |
| 176 | pub const winapi: CallingConvention = switch (builtin.target.cpu.arch) { | |
| 177 | 177 | .x86_64 => .{ .x86_64_win = .{} }, |
| 178 | 178 | .x86 => .{ .x86_stdcall = .{} }, |
| 179 | 179 | .aarch64, .aarch64_be => .{ .aarch64_aapcs_win = .{} }, |
| ... | ... | @@ -481,7 +481,9 @@ pub const CallingConvention = union(enum(u8)) { |
| 481 | 481 | |
| 482 | 482 | /// Returns the array of `std.Target.Cpu.Arch` to which this `CallingConvention` applies. |
| 483 | 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 | } | |
| 485 | 487 | |
| 486 | 488 | pub fn eql(a: CallingConvention, b: CallingConvention) bool { |
| 487 | 489 | return std.meta.eql(a, b); |
| ... | ... | @@ -490,7 +492,7 @@ pub const CallingConvention = union(enum(u8)) { |
| 490 | 492 | pub fn withStackAlign(cc: CallingConvention, incoming_stack_alignment: u64) CallingConvention { |
| 491 | 493 | const tag: CallingConvention.Tag = cc; |
| 492 | 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 | 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 | 9711 | } |
| 9712 | 9712 | fn checkCallConvSupportsVarArgs(sema: *Sema, block: *Block, src: LazySrcLoc, cc: std.builtin.CallingConvention.Tag) CompileError!void { |
| 9713 | 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 | 9716 | _ = fmt; |
| 9716 | 9717 | _ = options; |
| 9717 | for (calling_conventions_supporting_var_args, 0..) |cc_inner, i| { | |
| 9718 | if (i != 0) | |
| 9718 | var first = true; | |
| 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 | 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 | }; |
| 9724 | 9731 | |
| 9725 | 9732 | if (!callConvSupportsVarArgs(cc)) { |
| 9726 | const msg = msg: { | |
| 9727 | const msg = try sema.errMsg(src, "variadic function does not support '.{s}' calling convention", .{@tagName(cc)}); | |
| 9733 | return sema.failWithOwnedErrorMsg(block, msg: { | |
| 9734 | const msg = try sema.errMsg(src, "variadic function does not support '{s}' calling convention", .{@tagName(cc)}); | |
| 9728 | 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 | 9738 | break :msg msg; |
| 9731 | }; | |
| 9732 | return sema.failWithOwnedErrorMsg(block, msg); | |
| 9739 | }); | |
| 9733 | 9740 | } |
| 9734 | 9741 | } |
| 9735 | 9742 | |
| ... | ... | @@ -9857,9 +9864,9 @@ fn funcCommon( |
| 9857 | 9864 | .x86_64_interrupt, .x86_interrupt => { |
| 9858 | 9865 | const err_code_size = target.ptrBitWidth(); |
| 9859 | 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", .{}), | |
| 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}), | |
| 9862 | else => return sema.fail(block, param_src, "'Interrupt' calling convention supports up to 2 parameters, found {d}", .{i + 1}), | |
| 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)}), | |
| 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 }), | |
| 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 | 9872 | .arm_interrupt, |
| ... | ... | @@ -9870,8 +9877,8 @@ fn funcCommon( |
| 9870 | 9877 | .avr_interrupt, |
| 9871 | 9878 | .csky_interrupt, |
| 9872 | 9879 | .m68k_interrupt, |
| 9873 | => return sema.fail(block, param_src, "parameters are not allowed with 'Interrupt' calling convention", .{}), | |
| 9874 | .avr_signal => return sema.fail(block, param_src, "parameters are not allowed with 'Signal' calling convention", .{}), | |
| 9880 | => return sema.fail(block, param_src, "parameters are not allowed with '{s}' calling convention", .{@tagName(cc_resolved)}), | |
| 9881 | .avr_signal => return sema.fail(block, param_src, "parameters are not allowed with '{s}' calling convention", .{@tagName(cc_resolved)}), | |
| 9875 | 9882 | else => {}, |
| 9876 | 9883 | } |
| 9877 | 9884 | } |
| ... | ... | @@ -10220,7 +10227,7 @@ fn finishFunc( |
| 10220 | 10227 | for (formatter.archs, 0..) |arch, i| { |
| 10221 | 10228 | if (i != 0) |
| 10222 | 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 | 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 | 405 | if (fn_info.return_type == .generic_poison_type) { |
| 403 | 406 | try writer.writeAll("anytype"); |
src/arch/riscv64/CodeGen.zig+2-1| ... | ... | @@ -18,6 +18,7 @@ const Zcu = @import("../../Zcu.zig"); |
| 18 | 18 | const Package = @import("../../Package.zig"); |
| 19 | 19 | const InternPool = @import("../../InternPool.zig"); |
| 20 | 20 | const Compilation = @import("../../Compilation.zig"); |
| 21 | const target_util = @import("../../target.zig"); | |
| 21 | 22 | const trace = @import("../../tracy.zig").trace; |
| 22 | 23 | const codegen = @import("../../codegen.zig"); |
| 23 | 24 | |
| ... | ... | @@ -821,7 +822,7 @@ pub fn generate( |
| 821 | 822 | @intFromEnum(FrameIndex.stack_frame), |
| 822 | 823 | FrameAlloc.init(.{ |
| 823 | 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 | 828 | function.frame_allocs.set( |
src/arch/x86_64/CodeGen.zig+1-1| ... | ... | @@ -873,7 +873,7 @@ pub fn generate( |
| 873 | 873 | @intFromEnum(FrameIndex.stack_frame), |
| 874 | 874 | FrameAlloc.init(.{ |
| 875 | 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 | 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 | 210 | } |
| 211 | 211 | } |
| 212 | 212 | |
| 213 | test "alignstack" { | |
| 214 | try expect(fnWithAlignedStack() == 1234); | |
| 215 | } | |
| 216 | ||
| 217 | fn fnWithAlignedStack() i32 { | |
| 218 | @setAlignStack(256); | |
| 219 | return 1234; | |
| 220 | } | |
| 221 | ||
| 222 | 213 | test "implicitly decreasing slice alignment" { |
| 223 | 214 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; |
| 224 | 215 | 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 | 20 | try testing.expectEqual({}, @memset(@as([*]u8, @ptrFromInt(1))[0..0], undefined)); |
| 21 | 21 | try testing.expectEqual(noreturn, @TypeOf(if (true) @panic("") else {})); |
| 22 | 22 | try testing.expectEqual({}, @prefetch(&val, .{})); |
| 23 | try testing.expectEqual({}, @setAlignStack(16)); | |
| 24 | 23 | try testing.expectEqual({}, @setEvalBranchQuota(0)); |
| 25 | 24 | try testing.expectEqual({}, @setFloatMode(.optimized)); |
| 26 | 25 | try testing.expectEqual({}, @setRuntimeSafety(true)); |
test/behavior/type_info.zig+4-4| ... | ... | @@ -358,7 +358,7 @@ test "type info: function type info" { |
| 358 | 358 | fn testFunction() !void { |
| 359 | 359 | const foo_fn_type = @TypeOf(typeInfoFoo); |
| 360 | 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 | 362 | try expect(!foo_fn_info.@"fn".is_generic); |
| 363 | 363 | try expect(foo_fn_info.@"fn".params.len == 2); |
| 364 | 364 | try expect(foo_fn_info.@"fn".is_var_args); |
| ... | ... | @@ -374,7 +374,7 @@ fn testFunction() !void { |
| 374 | 374 | |
| 375 | 375 | const aligned_foo_fn_type = @TypeOf(typeInfoFooAligned); |
| 376 | 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 | 378 | try expect(!aligned_foo_fn_info.@"fn".is_generic); |
| 379 | 379 | try expect(aligned_foo_fn_info.@"fn".params.len == 2); |
| 380 | 380 | try expect(aligned_foo_fn_info.@"fn".is_var_args); |
| ... | ... | @@ -390,8 +390,8 @@ fn testFunction() !void { |
| 390 | 390 | try expect(aligned_foo_ptr_fn_info.pointer.sentinel == null); |
| 391 | 391 | } |
| 392 | 392 | |
| 393 | extern fn typeInfoFoo(a: usize, b: bool, ...) callconv(.C) usize; | |
| 394 | extern fn typeInfoFooAligned(a: usize, b: bool, ...) align(4) callconv(.C) usize; | |
| 393 | extern fn typeInfoFoo(a: usize, b: bool, ...) callconv(.c) usize; | |
| 394 | extern fn typeInfoFooAligned(a: usize, b: bool, ...) align(4) callconv(.c) usize; | |
| 395 | 395 | |
| 396 | 396 | test "type info: generic function types" { |
| 397 | 397 | const G1 = @typeInfo(@TypeOf(generic1)); |
test/behavior/typename.zig+3-3| ... | ... | @@ -79,9 +79,9 @@ test "basic" { |
| 79 | 79 | try expectEqualStrings("fn (comptime u32) void", @typeName(fn (comptime u32) void)); |
| 80 | 80 | try expectEqualStrings("fn (noalias []u8) void", @typeName(fn (noalias []u8) void)); |
| 81 | 81 | |
| 82 | 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)); | |
| 82 | 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)); | |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | test "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 | 7 | } |
| 8 | 8 | |
| 9 | 9 | // error |
| 10 | // backend=stage2 | |
| 11 | // target=native | |
| 10 | // target=x86_64-linux | |
| 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 | 13 | // :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 | 15 | // :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 | 8 | // backend=stage2 |
| 9 | 9 | // target=native |
| 10 | 10 | // |
| 11 | // :2:9: error: variable of type '*const fn () callconv(.Inline) void' must be const or comptime | |
| 11 | // :2:9: error: variable of type '*const fn () callconv(.@"inline") void' must be const or comptime | |
| 12 | 12 | // :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 | 1 | const Foo = packed struct(u32) { |
| 2 | 2 | x: u1, |
| 3 | 3 | }; |
| 4 | fn bar(_: Foo) callconv(.C) void {} | |
| 4 | fn bar(_: Foo) callconv(.c) void {} | |
| 5 | 5 | pub export fn entry() void { |
| 6 | 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 | 3 | export fn entry3() callconv(.AAPCSVFP) void {} |
| 4 | 4 | |
| 5 | 5 | // error |
| 6 | // backend=stage2 | |
| 7 | 6 | // target=x86_64-linux-none |
| 8 | 7 | // |
| 9 | // :1:30: error: callconv 'APCS' is only available on ARM, not x86_64 | |
| 10 | // :2:30: error: callconv 'AAPCS' is only available on ARM, not x86_64 | |
| 11 | // :3:30: error: callconv 'AAPCSVFP' is only available on ARM, not x86_64 | |
| 8 | // :1:30: error: callconv 'arm_apcs' only available on architectures 'arm', 'armeb', 'thumb', 'thumbeb' | |
| 9 | // :2:30: error: callconv 'arm_aapcs' only available on architectures 'arm', 'armeb', 'thumb', 'thumbeb' | |
| 10 | // :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 | export fn entry() callconv(.Signal) void {} | |
| 1 | export fn entry() callconv(.avr_signal) void {} | |
| 2 | 2 | |
| 3 | 3 | // error |
| 4 | 4 | // backend=stage2 |
| 5 | 5 | // target=x86_64-linux-none |
| 6 | 6 | // |
| 7 | // :1:29: error: callconv 'Signal' is only available on AVR, not x86_64 | |
| 7 | // :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 | const F1 = fn () callconv(.Stdcall) void; | |
| 2 | const F2 = fn () callconv(.Fastcall) void; | |
| 3 | const F3 = fn () callconv(.Thiscall) void; | |
| 1 | const F1 = fn () callconv(.{ .x86_stdcall = .{} }) void; | |
| 2 | const F2 = fn () callconv(.{ .x86_fastcall = .{} }) void; | |
| 3 | const F3 = fn () callconv(.{ .x86_thiscall = .{} }) void; | |
| 4 | 4 | export fn entry1() void { |
| 5 | 5 | const a: F1 = undefined; |
| 6 | 6 | _ = a; |
| ... | ... | @@ -18,6 +18,6 @@ export fn entry3() void { |
| 18 | 18 | // backend=stage2 |
| 19 | 19 | // target=x86_64-linux-none |
| 20 | 20 | // |
| 21 | // :1:28: error: callconv 'Stdcall' is only available on x86, not x86_64 | |
| 22 | // :2:28: error: callconv 'Fastcall' is only available on x86, not x86_64 | |
| 23 | // :3:28: error: callconv 'Thiscall' is only available on x86, not x86_64 | |
| 21 | // :1:28: error: callconv 'x86_stdcall' only available on architectures 'x86' | |
| 22 | // :2:28: error: callconv 'x86_fastcall' only available on architectures 'x86' | |
| 23 | // :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 @@ |
| 1 | export 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 | 4 | comptime callbackArg: fn () callconv(.Inline) void, |
| 5 | 5 | ) void { |
| 6 | 6 | _ = &(struct { |
| 7 | pub fn callback() callconv(.C) void { | |
| 7 | pub fn callback() callconv(.c) void { | |
| 8 | 8 | callbackArg(); |
| 9 | 9 | } |
| 10 | 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 | 3 | } |
| 4 | 4 | |
| 5 | 5 | // error |
| 6 | // backend=stage2 | |
| 7 | // target=native | |
| 6 | // target=x86_64-linux | |
| 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 | 4 | } |
| 5 | 5 | |
| 6 | 6 | // error |
| 7 | // backend=stage2 | |
| 8 | // target=native | |
| 7 | // target=x86_64-linux | |
| 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 | 14 | } |
| 15 | 15 | |
| 16 | 16 | // error |
| 17 | // backend=stage2 | |
| 18 | // target=native | |
| 17 | // target=x86_64-linux | |
| 19 | 18 | // |
| 20 | // :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' | |
| 19 | // :1:38: error: expected type 'fn (i32) i32', found 'fn (i32) callconv(.c) i32' | |
| 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 | 15 | } |
| 16 | 16 | |
| 17 | 17 | // error |
| 18 | // backend=stage2 | |
| 19 | // target=native | |
| 18 | // target=x86_64-linux | |
| 20 | 19 | // |
| 21 | // :1:15: error: comptime parameters not allowed in function with calling convention 'C' | |
| 22 | // :5:30: error: comptime parameters not allowed in function with calling convention 'C' | |
| 23 | // :6:30: error: generic 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' | |
| 21 | // :5:30: error: comptime parameters not allowed in function with calling convention 'x86_64_sysv' | |
| 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 | comptime { | |
| 2 | @setAlignStack(1); | |
| 3 | } | |
| 4 | ||
| 5 | 1 | comptime { |
| 6 | 2 | @branchHint(.cold); |
| 7 | 3 | } |
| ... | ... | @@ -54,16 +50,15 @@ comptime { |
| 54 | 50 | // backend=stage2 |
| 55 | 51 | // target=native |
| 56 | 52 | // |
| 57 | // :2:5: error: '@setAlignStack' outside function scope | |
| 58 | // :6:5: error: '@branchHint' outside function scope | |
| 59 | // :10:5: error: '@src' outside function scope | |
| 60 | // :14:5: error: '@returnAddress' outside function scope | |
| 61 | // :18:5: error: '@frameAddress' outside function scope | |
| 62 | // :22:5: error: '@breakpoint' outside function scope | |
| 63 | // :26:5: error: '@cVaArg' outside function scope | |
| 64 | // :30:5: error: '@cVaCopy' outside function scope | |
| 65 | // :34:5: error: '@cVaEnd' outside function scope | |
| 66 | // :38:5: error: '@cVaStart' outside function scope | |
| 67 | // :42:5: error: '@workItemId' outside function scope | |
| 68 | // :46:5: error: '@workGroupSize' outside function scope | |
| 69 | // :50:5: error: '@workGroupId' outside function scope | |
| 53 | // :2:5: error: '@branchHint' outside function scope | |
| 54 | // :6:5: error: '@src' outside function scope | |
| 55 | // :10:5: error: '@returnAddress' outside function scope | |
| 56 | // :14:5: error: '@frameAddress' outside function scope | |
| 57 | // :18:5: error: '@breakpoint' outside function scope | |
| 58 | // :22:5: error: '@cVaArg' outside function scope | |
| 59 | // :26:5: error: '@cVaCopy' outside function scope | |
| 60 | // :30:5: error: '@cVaEnd' outside function scope | |
| 61 | // :34:5: error: '@cVaStart' outside function scope | |
| 62 | // :38:5: error: '@workItemId' outside function scope | |
| 63 | // :42:5: error: '@workGroupSize' outside function scope | |
| 64 | // :46: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 | 4 | } |
| 5 | 5 | |
| 6 | 6 | // error |
| 7 | // backend=stage2 | |
| 8 | // target=native | |
| 7 | // target=x86_64-linux | |
| 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 | 10 | // :2:17: note: enum tag type 'u2' is not extern compatible |
| 12 | 11 | // :2:17: note: only integers with 0, 8, 16, 32, 64 and 128 bits are extern compatible |
| 13 | 12 | // :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 | 8 | } |
| 9 | 9 | |
| 10 | 10 | // error |
| 11 | // backend=stage2 | |
| 12 | // target=native | |
| 11 | // target=x86_64-linux | |
| 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 | 14 | // :6:17: note: only extern structs and ABI sized packed structs are extern compatible |
| 16 | 15 | // :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 | 8 | } |
| 9 | 9 | |
| 10 | 10 | // error |
| 11 | // backend=stage2 | |
| 12 | // target=native | |
| 11 | // target=x86_64-linux | |
| 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 | 14 | // :6:17: note: only extern unions and ABI sized packed unions are extern compatible |
| 16 | 15 | // :1:13: note: union declared here |
test/cases/compile_errors/invalid_extern_function_call.zig+1-1| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | const x = @extern(*const fn () callconv(.C) void, .{ .name = "foo" }); | |
| 1 | const x = @extern(*const fn () callconv(.c) void, .{ .name = "foo" }); | |
| 2 | 2 | |
| 3 | 3 | export fn entry0() void { |
| 4 | 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 | 9 | export fn signal_ret() callconv(.Signal) noreturn {} |
| 10 | 10 | |
| 11 | 11 | // error |
| 12 | // backend=stage2 | |
| 13 | 12 | // target=x86_64-linux |
| 14 | // | |
| 15 | // :1:28: error: first parameter of function with '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 integer | |
| 17 | // :3:51: error: 'Interrupt' calling convention supports up to 2 parameters, found 3 | |
| 18 | // :4:69: error: function with calling convention 'Interrupt' must return 'void' or 'noreturn' | |
| 19 | // :8:24: error: parameters are not allowed with 'Signal' calling convention | |
| 20 | // :9:34: error: callconv 'Signal' is only available on AVR, not x86_64 | |
| 13 | // | |
| 14 | // :1:28: error: first parameter of function with 'x86_64_interrupt' calling convention must be a pointer type | |
| 15 | // :2:43: error: second parameter of function with 'x86_64_interrupt' calling convention must be a 64-bit integer | |
| 16 | // :3:51: error: 'x86_64_interrupt' calling convention supports up to 2 parameters, found 3 | |
| 17 | // :4:69: error: function with calling convention 'x86_64_interrupt' must return 'void' or 'noreturn' | |
| 18 | // :8:24: error: parameters are not allowed with 'avr_signal' calling convention | |
| 19 | // :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 | 9 | // backend=llvm |
| 10 | 10 | // 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 | 13 | } |
| 14 | 14 | |
| 15 | 15 | // error |
| 16 | // backend=stage2 | |
| 17 | // target=native | |
| 16 | // target=x86_64-linux | |
| 18 | 17 | // |
| 19 | // :1:1: error: variadic function does not support '.Unspecified' calling convention | |
| 20 | // :1:1: note: supported calling conventions: '.C' | |
| 21 | // :1:1: error: variadic function does not support '.Inline' calling convention | |
| 22 | // :1:1: note: supported calling conventions: '.C' | |
| 18 | // :1:1: error: variadic function does not support 'auto' calling convention | |
| 19 | // :1:1: note: supported calling conventions: 'x86_64_sysv', 'x86_64_win' | |
| 20 | // :1:1: error: variadic function does not support 'inline' calling convention | |
| 21 | // :1:1: note: supported calling conventions: 'x86_64_sysv', 'x86_64_win' | |
| 23 | 22 | // :2:1: error: generic function cannot be variadic |
test/cases/compile_errors/noinline_fn_cc_inline.zig+2-3| ... | ... | @@ -1,5 +1,4 @@ |
| 1 | const cc = .Inline; | |
| 2 | noinline fn foo() callconv(cc) void {} | |
| 1 | noinline fn foo() callconv(.@"inline") void {} | |
| 3 | 2 | |
| 4 | 3 | comptime { |
| 5 | 4 | _ = foo; |
| ... | ... | @@ -9,4 +8,4 @@ comptime { |
| 9 | 8 | // backend=stage2 |
| 10 | 9 | // 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 | 1 | const S = extern struct { |
| 2 | a: fn () callconv(.C) void, | |
| 2 | a: fn () callconv(.c) void, | |
| 3 | 3 | }; |
| 4 | 4 | comptime { |
| 5 | 5 | _ = @sizeOf(S) == 1; |
| 6 | 6 | } |
| 7 | 7 | comptime { |
| 8 | _ = [*c][4]fn () callconv(.C) void; | |
| 8 | _ = [*c][4]fn () callconv(.c) void; | |
| 9 | 9 | } |
| 10 | 10 | |
| 11 | 11 | // error |
| 12 | 12 | // backend=stage2 |
| 13 | 13 | // 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 | 16 | // :2:8: note: type has no guaranteed in-memory representation |
| 17 | 17 | // :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 | 19 | // :8:13: note: type has no guaranteed in-memory representation |
| 20 | 20 | // :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 | 12 | } |
| 13 | 13 | |
| 14 | 14 | // error |
| 15 | // backend=stage2 | |
| 16 | // target=native | |
| 15 | // target=x86_64-linux | |
| 17 | 16 | // |
| 18 | // :1:13: error: variadic function does not support '.Unspecified' calling convention | |
| 19 | // :1:13: note: supported calling conventions: '.C' | |
| 17 | // :1:13: error: variadic function does not support 'auto' calling convention | |
| 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 | 1 | const GuSettings = struct { |
| 2 | fin: ?fn (c_int) callconv(.C) void, | |
| 2 | fin: ?fn (c_int) callconv(.c) void, | |
| 3 | 3 | }; |
| 4 | 4 | pub export fn callbackFin(id: c_int, arg: ?*anyopaque) void { |
| 5 | 5 | const settings: ?*GuSettings = @as(?*GuSettings, @ptrFromInt(@intFromPtr(arg))); |
| ... | ... | @@ -13,4 +13,4 @@ pub export fn callbackFin(id: c_int, arg: ?*anyopaque) void { |
| 13 | 13 | // |
| 14 | 14 | // :5:54: error: pointer to comptime-only type '?*tmp.GuSettings' must be comptime-known, but operand is runtime-known |
| 15 | 15 | // :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 type | |
| 16 | // :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 @@ |
| 1 | export 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 @@ |
| 1 | export 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 | extern fn Text(str: []const u8, num: i32) callconv(.C) void; | |
| 1 | extern fn Text(str: []const u8, num: i32) callconv(.c) void; | |
| 2 | 2 | export fn entry() void { |
| 3 | 3 | _ = Text; |
| 4 | 4 | } |
| 5 | 5 | |
| 6 | 6 | // error |
| 7 | // backend=stage2 | |
| 8 | // target=native | |
| 7 | // target=x86_64-linux | |
| 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 | 10 | // :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 | const fn_ty = ?fn ([*c]u8, ...) callconv(.C) void; | |
| 1 | const fn_ty = ?fn ([*c]u8, ...) callconv(.c) void; | |
| 2 | 2 | extern fn fn_decl(fmt: [*:0]u8, ...) void; |
| 3 | 3 | |
| 4 | 4 | export fn main() void { |
| ... | ... | @@ -10,6 +10,6 @@ export fn main() void { |
| 10 | 10 | // backend=stage2 |
| 11 | 11 | // 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 | 14 | // :5:22: note: parameter 0 '[*:0]u8' cannot cast into '[*c]u8' |
| 15 | 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 | fn entry() callconv(.C) void {} | |
| 1 | fn entry() callconv(.c) void {} | |
| 2 | 2 | comptime { |
| 3 | 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 | 9 | // c_frontend=clang |
| 10 | 10 | // |
| 11 | 11 | // pub const struct_empty_struct = extern struct {}; |
| 12 | // pub fn foo() callconv(.C) void { | |
| 12 | // pub fn foo() callconv(.c) void { | |
| 13 | 13 | // const bar = struct { |
| 14 | 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 | 484 | \\ fnptr_attr_ty qux; |
| 485 | 485 | \\}; |
| 486 | 486 | , &[_][]const u8{ |
| 487 | \\pub const fnptr_ty = ?*const fn () callconv(.C) void; | |
| 488 | \\pub const fnptr_attr_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; | |
| 489 | 489 | \\pub const struct_foo = extern struct { |
| 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), | |
| 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), | |
| 492 | 492 | \\ baz: fnptr_ty = @import("std").mem.zeroes(fnptr_ty), |
| 493 | 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 | 735 | \\static void bar(void) {} |
| 736 | 736 | , &[_][]const u8{ |
| 737 | 737 | \\pub export fn foo() void {} |
| 738 | \\pub fn bar() callconv(.C) void {} | |
| 738 | \\pub fn bar() callconv(.c) void {} | |
| 739 | 739 | }); |
| 740 | 740 | |
| 741 | 741 | cases.add("typedef void", |
| ... | ... | @@ -769,7 +769,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 769 | 769 | \\pub export fn bar() void { |
| 770 | 770 | \\ var func_ptr: ?*anyopaque = @as(?*anyopaque, @ptrCast(&foo)); |
| 771 | 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 | 773 | \\ _ = &typed_func_ptr; |
| 774 | 774 | \\} |
| 775 | 775 | }); |
| ... | ... | @@ -839,9 +839,9 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 839 | 839 | \\ lws_callback_function *callback_http; |
| 840 | 840 | \\}; |
| 841 | 841 | , &[_][]const u8{ |
| 842 | \\pub const lws_callback_function = fn () callconv(.C) void; | |
| 842 | \\pub const lws_callback_function = fn () callconv(.c) void; | |
| 843 | 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 | 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 | 867 | \\}; |
| 868 | 868 | , &[_][]const u8{ |
| 869 | 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 | 873 | \\pub const Foo = struct_Foo; |
| ... | ... | @@ -1111,7 +1111,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 1111 | 1111 | cases.add("__cdecl doesn't mess up function pointers", |
| 1112 | 1112 | \\void foo(void (__cdecl *fn_ptr)(void)); |
| 1113 | 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 | }); |
| 1116 | 1116 | |
| 1117 | 1117 | cases.add("void cast", |
| ... | ... | @@ -1477,8 +1477,8 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 1477 | 1477 | \\typedef void (*fn0)(); |
| 1478 | 1478 | \\typedef void (*fn1)(char); |
| 1479 | 1479 | , &[_][]const u8{ |
| 1480 | \\pub const fn0 = ?*const fn (...) callconv(.C) void; | |
| 1481 | \\pub const fn1 = ?*const fn (u8) callconv(.C) void; | |
| 1480 | \\pub const fn0 = ?*const fn (...) callconv(.c) void; | |
| 1481 | \\pub const fn1 = ?*const fn (u8) callconv(.c) void; | |
| 1482 | 1482 | }); |
| 1483 | 1483 | |
| 1484 | 1484 | cases.addWithTarget("Calling convention", .{ |
| ... | ... | @@ -1492,11 +1492,11 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 1492 | 1492 | \\void __attribute__((cdecl)) foo4(float *a); |
| 1493 | 1493 | \\void __attribute__((thiscall)) foo5(float *a); |
| 1494 | 1494 | , &[_][]const u8{ |
| 1495 | \\pub extern fn foo1(a: [*c]f32) callconv(.Fastcall) void; | |
| 1496 | \\pub extern fn foo2(a: [*c]f32) callconv(.Stdcall) void; | |
| 1497 | \\pub extern fn foo3(a: [*c]f32) callconv(.Vectorcall) void; | |
| 1495 | \\pub extern fn foo1(a: [*c]f32) callconv(.{ .x86_fastcall = .{} }) void; | |
| 1496 | \\pub extern fn foo2(a: [*c]f32) callconv(.{ .x86_stdcall = .{} }) void; | |
| 1497 | \\pub extern fn foo3(a: [*c]f32) callconv(.{ .x86_vectorcall = .{} }) void; | |
| 1498 | 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 | }); |
| 1501 | 1501 | |
| 1502 | 1502 | cases.addWithTarget("Calling convention", std.Target.Query.parse(.{ |
| ... | ... | @@ -1506,8 +1506,8 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 1506 | 1506 | \\void __attribute__((pcs("aapcs"))) foo1(float *a); |
| 1507 | 1507 | \\void __attribute__((pcs("aapcs-vfp"))) foo2(float *a); |
| 1508 | 1508 | , &[_][]const u8{ |
| 1509 | \\pub extern fn foo1(a: [*c]f32) callconv(.AAPCS) void; | |
| 1510 | \\pub extern fn foo2(a: [*c]f32) callconv(.AAPCSVFP) void; | |
| 1509 | \\pub extern fn foo1(a: [*c]f32) callconv(.{ .arm_aapcs = .{} }) void; | |
| 1510 | \\pub extern fn foo2(a: [*c]f32) callconv(.{ .arm_aapcs_vfp = .{} }) void; | |
| 1511 | 1511 | }); |
| 1512 | 1512 | |
| 1513 | 1513 | cases.addWithTarget("Calling convention", std.Target.Query.parse(.{ |
| ... | ... | @@ -1516,7 +1516,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 1516 | 1516 | }) catch unreachable, |
| 1517 | 1517 | \\void __attribute__((aarch64_vector_pcs)) foo1(float *a); |
| 1518 | 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 | }); |
| 1521 | 1521 | |
| 1522 | 1522 | cases.add("Parameterless function prototypes", |
| ... | ... | @@ -1533,8 +1533,8 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 1533 | 1533 | \\pub export fn b() void {} |
| 1534 | 1534 | \\pub extern fn c(...) void; |
| 1535 | 1535 | \\pub extern fn d() void; |
| 1536 | \\pub fn e() callconv(.C) void {} | |
| 1537 | \\pub fn f() callconv(.C) void {} | |
| 1536 | \\pub fn e() callconv(.c) void {} | |
| 1537 | \\pub fn f() callconv(.c) void {} | |
| 1538 | 1538 | \\pub extern fn g() void; |
| 1539 | 1539 | \\pub extern fn h() void; |
| 1540 | 1540 | }); |
| ... | ... | @@ -1555,7 +1555,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 1555 | 1555 | \\ char *arr1[10] ={0}; |
| 1556 | 1556 | \\} |
| 1557 | 1557 | , &[_][]const u8{ |
| 1558 | \\pub fn foo() callconv(.C) void { | |
| 1558 | \\pub fn foo() callconv(.c) void { | |
| 1559 | 1559 | \\ var arr: [10]u8 = [1]u8{ |
| 1560 | 1560 | \\ 1, |
| 1561 | 1561 | \\ } ++ [1]u8{0} ** 9; |
| ... | ... | @@ -1686,13 +1686,13 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 1686 | 1686 | \\extern char (*fn_ptr2)(int, float); |
| 1687 | 1687 | \\#define bar fn_ptr2 |
| 1688 | 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 | 1691 | \\pub inline fn foo() void { |
| 1692 | 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 | 1697 | \\pub inline fn bar(arg_1: c_int, arg_2: f32) u8 { |
| 1698 | 1698 | \\ return fn_ptr2.?(arg_1, arg_2); |
| ... | ... | @@ -1714,8 +1714,8 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 1714 | 1714 | \\#define glClearPFN PFNGLCLEARPROC |
| 1715 | 1715 | , &[_][]const u8{ |
| 1716 | 1716 | \\pub const GLbitfield = c_uint; |
| 1717 | \\pub const PFNGLCLEARPROC = ?*const fn (GLbitfield) callconv(.C) void; | |
| 1718 | \\pub const OpenGLProc = ?*const fn () callconv(.C) void; | |
| 1717 | \\pub const PFNGLCLEARPROC = ?*const fn (GLbitfield) callconv(.c) void; | |
| 1718 | \\pub const OpenGLProc = ?*const fn () callconv(.c) void; | |
| 1719 | 1719 | \\const struct_unnamed_1 = extern struct { |
| 1720 | 1720 | \\ Clear: PFNGLCLEARPROC = @import("std").mem.zeroes(PFNGLCLEARPROC), |
| 1721 | 1721 | \\}; |
| ... | ... | @@ -2691,9 +2691,9 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 2691 | 2691 | \\ return 0; |
| 2692 | 2692 | \\} |
| 2693 | 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 | 2695 | \\ _ = &f; |
| 2696 | \\ var b: ?*const fn () callconv(.C) c_int = &baz; | |
| 2696 | \\ var b: ?*const fn () callconv(.c) c_int = &baz; | |
| 2697 | 2697 | \\ _ = &b; |
| 2698 | 2698 | \\ f.?(); |
| 2699 | 2699 | \\ f.?(); |
| ... | ... | @@ -3048,8 +3048,8 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 3048 | 3048 | \\ baz(); |
| 3049 | 3049 | \\} |
| 3050 | 3050 | , &[_][]const u8{ |
| 3051 | \\pub fn bar() callconv(.C) void {} | |
| 3052 | \\pub export fn foo(arg_baz: ?*const fn () callconv(.C) [*c]c_int) void { | |
| 3051 | \\pub fn bar() callconv(.c) void {} | |
| 3052 | \\pub export fn foo(arg_baz: ?*const fn () callconv(.c) [*c]c_int) void { | |
| 3053 | 3053 | \\ var baz = arg_baz; |
| 3054 | 3054 | \\ _ = &baz; |
| 3055 | 3055 | \\ bar(); |
| ... | ... | @@ -3112,7 +3112,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 3112 | 3112 | \\ do {} while (0); |
| 3113 | 3113 | \\} |
| 3114 | 3114 | , &[_][]const u8{ |
| 3115 | \\pub fn foo() callconv(.C) void { | |
| 3115 | \\pub fn foo() callconv(.c) void { | |
| 3116 | 3116 | \\ if (true) while (true) { |
| 3117 | 3117 | \\ if (!false) break; |
| 3118 | 3118 | \\ }; |
| ... | ... | @@ -3212,10 +3212,10 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 3212 | 3212 | \\void c(void) {} |
| 3213 | 3213 | \\static void foo() {} |
| 3214 | 3214 | , &[_][]const u8{ |
| 3215 | \\pub fn a() callconv(.C) void {} | |
| 3216 | \\pub fn b() callconv(.C) void {} | |
| 3215 | \\pub fn a() callconv(.c) void {} | |
| 3216 | \\pub fn b() callconv(.c) void {} | |
| 3217 | 3217 | \\pub export fn c() void {} |
| 3218 | \\pub fn foo() callconv(.C) void {} | |
| 3218 | \\pub fn foo() callconv(.c) void {} | |
| 3219 | 3219 | }); |
| 3220 | 3220 | |
| 3221 | 3221 | cases.add("casting away const and volatile", |