Files
zig/test/cases/compile_errors/unreachable_in_naked_func.zig
Jacob Young 89d660c3eb Sema: improve new error messages related to naked functions
* pass a source location to all safety checks
 * add notes about what is disallowed in naked functions

Closes #16651
2023-08-02 16:12:30 -07:00

31 lines
801 B
Zig

fn runtimeSafetyDefault() callconv(.Naked) void {
unreachable;
}
fn runtimeSafetyOn() callconv(.Naked) void {
@setRuntimeSafety(true);
unreachable;
}
fn runtimeSafetyOff() callconv(.Naked) void {
@setRuntimeSafety(false);
unreachable;
}
comptime {
_ = &runtimeSafetyDefault;
_ = &runtimeSafetyOn;
_ = &runtimeSafetyOff;
}
// error
// backend=llvm
// target=native
//
// :2:5: error: runtime safety check not allowed in naked function
// :2:5: note: use @setRuntimeSafety to disable runtime safety
// :2:5: note: the end of a naked function is implicitly unreachable
// :7:5: error: runtime safety check not allowed in naked function
// :7:5: note: use @setRuntimeSafety to disable runtime safety
// :7:5: note: the end of a naked function is implicitly unreachable