Sema: add and improve some callconv compile errors

This commit is contained in:
mlugg 2024-10-17 09:09:35 +01:00
parent 73f4c68005
commit 8d5ac6bdea
No known key found for this signature in database
GPG Key ID: 3F5B7DCCBF4AF02E
7 changed files with 25 additions and 13 deletions

View File

@ -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),
}),

View File

@ -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'

View File

@ -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

View File

@ -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'

View File

@ -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'

View File

@ -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'

View File

@ -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'