diff options
| author | Jacob Young <jacobly0@users.noreply.github.com> | 2023-07-31 01:50:54 -0400 |
|---|---|---|
| committer | Jacob Young <jacobly0@users.noreply.github.com> | 2023-07-31 01:58:10 -0400 |
| commit | 2ba787e3038d8776599fb968b3ddec6b7a62a3f3 (patch) | |
| tree | 967663a3f1226f48ac1405416f7bc002074430da /src/Module.zig | |
| parent | 9831f272383a66392ebeadbc60d8176f44b3553c (diff) | |
| download | zig-2ba787e3038d8776599fb968b3ddec6b7a62a3f3.tar.gz zig-2ba787e3038d8776599fb968b3ddec6b7a62a3f3.zip | |
Sema: restrict what can appear in a naked function
* Disable runtime calls, since it is not possible to know the proper
stack adjustment to follow the callee abi.
* Disable runtime returns, since it is not possible to know where the
return address is stored in general.
* Allow implicit returns regardless of the return type, which allows
naked functions with a non-void return type to be written.
Diffstat (limited to 'src/Module.zig')
| -rw-r--r-- | src/Module.zig | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/Module.zig b/src/Module.zig index 41236880c5..f5438ebb9f 100644 --- a/src/Module.zig +++ b/src/Module.zig @@ -4186,6 +4186,7 @@ pub fn semaFile(mod: *Module, file: *File) SemaError!void { .owner_decl = new_decl, .owner_decl_index = new_decl_index, .func_index = .none, + .func_is_naked = false, .fn_ret_ty = Type.void, .fn_ret_ty_ies = null, .owner_func_index = .none, @@ -4268,6 +4269,7 @@ fn semaDecl(mod: *Module, decl_index: Decl.Index) !bool { .owner_decl = decl, .owner_decl_index = decl_index, .func_index = .none, + .func_is_naked = false, .fn_ret_ty = Type.void, .fn_ret_ty_ies = null, .owner_func_index = .none, @@ -5213,6 +5215,7 @@ pub fn analyzeFnBody(mod: *Module, func_index: InternPool.Index, arena: Allocato .owner_decl = decl, .owner_decl_index = decl_index, .func_index = func_index, + .func_is_naked = fn_ty_info.cc == .Naked, .fn_ret_ty = fn_ty_info.return_type.toType(), .fn_ret_ty_ies = null, .owner_func_index = func_index, |
