diff --git a/src/Sema.zig b/src/Sema.zig index 1957b94b5c..00448c47ca 100644 --- a/src/Sema.zig +++ b/src/Sema.zig @@ -10195,6 +10195,18 @@ fn finishFunc( return sema.failWithOwnedErrorMsg(block, msg); } + validate_incoming_stack_align: { + const a: u64 = switch (cc_resolved) { + inline else => |payload| if (@TypeOf(payload) != void and @hasField(@TypeOf(payload), "incoming_stack_alignment")) + payload.incoming_stack_alignment orelse break :validate_incoming_stack_align + else + break :validate_incoming_stack_align, + }; + if (!std.math.isPowerOfTwo(a)) { + return sema.fail(block, cc_src, "calling convention incoming stack alignment '{d}' is not a power of two", .{a}); + } + } + switch (cc_resolved) { .x86_64_interrupt, .x86_interrupt, @@ -10211,7 +10223,7 @@ fn finishFunc( return sema.fail(block, ret_ty_src, "function with calling convention '{s}' must return 'void' or 'noreturn'", .{@tagName(cc_resolved)}); }, .@"inline" => if (is_noinline) { - return sema.fail(block, cc_src, "'noinline' function cannot have callconv 'inline'", .{}); + return sema.fail(block, cc_src, "'noinline' function cannot have calling convention 'inline'", .{}); }, else => {}, } @@ -10231,12 +10243,12 @@ fn finishFunc( } } }; - return sema.fail(block, cc_src, "callconv '{s}' only available on architectures {}", .{ + return sema.fail(block, cc_src, "calling convention '{s}' only available on architectures {}", .{ @tagName(cc_resolved), ArchListFormatter{ .archs = allowed_archs }, }); }, - .bad_backend => |bad_backend| return sema.fail(block, cc_src, "callconv '{s}' not supported by compiler backend '{s}'", .{ + .bad_backend => |bad_backend| return sema.fail(block, cc_src, "calling convention '{s}' not supported by compiler backend '{s}'", .{ @tagName(cc_resolved), @tagName(bad_backend), }), diff --git a/test/cases/compile_errors/callconv_apcs_aapcs_aapcsvfp_on_unsupported_platform.zig b/test/cases/compile_errors/callconv_apcs_aapcs_aapcsvfp_on_unsupported_platform.zig index 78315f7ba2..ce1c80e9e6 100644 --- a/test/cases/compile_errors/callconv_apcs_aapcs_aapcsvfp_on_unsupported_platform.zig +++ b/test/cases/compile_errors/callconv_apcs_aapcs_aapcsvfp_on_unsupported_platform.zig @@ -5,6 +5,6 @@ export fn entry3() callconv(.AAPCSVFP) void {} // error // target=x86_64-linux-none // -// :1:30: error: callconv 'arm_apcs' only available on architectures 'arm', 'armeb', 'thumb', 'thumbeb' -// :2:30: error: callconv 'arm_aapcs' only available on architectures 'arm', 'armeb', 'thumb', 'thumbeb' -// :3:30: error: callconv 'arm_aapcs_vfp' only available on architectures 'arm', 'armeb', 'thumb', 'thumbeb' +// :1:30: error: calling convention 'arm_apcs' only available on architectures 'arm', 'armeb', 'thumb', 'thumbeb' +// :2:30: error: calling convention 'arm_aapcs' only available on architectures 'arm', 'armeb', 'thumb', 'thumbeb' +// :3:30: error: calling convention 'arm_aapcs_vfp' only available on architectures 'arm', 'armeb', 'thumb', 'thumbeb' diff --git a/test/cases/compile_errors/callconv_interrupt_on_unsupported_platform.zig b/test/cases/compile_errors/callconv_interrupt_on_unsupported_platform.zig index 8208e2ffa3..97ef0aa1d6 100644 --- a/test/cases/compile_errors/callconv_interrupt_on_unsupported_platform.zig +++ b/test/cases/compile_errors/callconv_interrupt_on_unsupported_platform.zig @@ -4,4 +4,4 @@ export fn entry() callconv(.Interrupt) void {} // backend=stage2 // target=aarch64-linux-none // -// :1:29: error: callconv 'Interrupt' is only available on x86, x86_64, AVR, and MSP430, not aarch64 +// :1:29: error: calling convention 'Interrupt' is only available on x86, x86_64, AVR, and MSP430, not aarch64 diff --git a/test/cases/compile_errors/callconv_signal_on_unsupported_platform.zig b/test/cases/compile_errors/callconv_signal_on_unsupported_platform.zig index 4dfb098eae..adc91d04e9 100644 --- a/test/cases/compile_errors/callconv_signal_on_unsupported_platform.zig +++ b/test/cases/compile_errors/callconv_signal_on_unsupported_platform.zig @@ -4,4 +4,4 @@ export fn entry() callconv(.avr_signal) void {} // backend=stage2 // target=x86_64-linux-none // -// :1:29: error: callconv 'avr_signal' only available on architectures 'avr' +// :1:29: error: calling convention 'avr_signal' only available on architectures 'avr' diff --git a/test/cases/compile_errors/callconv_stdcall_fastcall_thiscall_on_unsupported_platform.zig b/test/cases/compile_errors/callconv_stdcall_fastcall_thiscall_on_unsupported_platform.zig index 08149cc123..28036c309c 100644 --- a/test/cases/compile_errors/callconv_stdcall_fastcall_thiscall_on_unsupported_platform.zig +++ b/test/cases/compile_errors/callconv_stdcall_fastcall_thiscall_on_unsupported_platform.zig @@ -18,6 +18,6 @@ export fn entry3() void { // backend=stage2 // target=x86_64-linux-none // -// :1:28: error: callconv 'x86_stdcall' only available on architectures 'x86' -// :2:28: error: callconv 'x86_fastcall' only available on architectures 'x86' -// :3:28: error: callconv 'x86_thiscall' only available on architectures 'x86' +// :1:28: error: calling convention 'x86_stdcall' only available on architectures 'x86' +// :2:28: error: calling convention 'x86_fastcall' only available on architectures 'x86' +// :3:28: error: calling convention 'x86_thiscall' only available on architectures 'x86' diff --git a/test/cases/compile_errors/invalid_func_for_callconv.zig b/test/cases/compile_errors/invalid_func_for_callconv.zig index f82b3a63b4..ef20d0ab8f 100644 --- a/test/cases/compile_errors/invalid_func_for_callconv.zig +++ b/test/cases/compile_errors/invalid_func_for_callconv.zig @@ -16,4 +16,4 @@ export fn signal_ret() callconv(.Signal) noreturn {} // :3:51: error: 'x86_64_interrupt' calling convention supports up to 2 parameters, found 3 // :4:69: error: function with calling convention 'x86_64_interrupt' must return 'void' or 'noreturn' // :8:24: error: parameters are not allowed with 'avr_signal' calling convention -// :9:34: error: callconv 'avr_signal' only available on architectures 'avr' +// :9:34: error: calling convention 'avr_signal' only available on architectures 'avr' diff --git a/test/cases/compile_errors/noinline_fn_cc_inline.zig b/test/cases/compile_errors/noinline_fn_cc_inline.zig index ac7e93fcdb..eee97e683b 100644 --- a/test/cases/compile_errors/noinline_fn_cc_inline.zig +++ b/test/cases/compile_errors/noinline_fn_cc_inline.zig @@ -8,4 +8,4 @@ comptime { // backend=stage2 // target=native // -// :1:29: error: 'noinline' function cannot have callconv 'inline' +// :1:29: error: 'noinline' function cannot have calling convention 'inline'