| author | |
| committer | |
| log | 0eddf0cbc0a88121a67239d5899dca8a39c39cd8 |
| tree | 3d271460ab2998ba842e350022523fe73929f4a7 |
| parent | 3db8cffa3b383011471f425983a7e98ad8a46aa5 |
Closes #139872 files changed, 9 insertions(+), 1 deletions(-)
src/Sema.zig+3-1| ... | ... | @@ -8820,7 +8820,9 @@ fn analyzeParameter( |
| 8820 | 8820 | }; |
| 8821 | 8821 | return sema.failWithOwnedErrorMsg(msg); |
| 8822 | 8822 | } |
| 8823 | if (!this_generic and is_noalias and !param.ty.isPtrAtRuntime()) { | |
| 8823 | if (!sema.is_generic_instantiation and !this_generic and is_noalias and | |
| 8824 | !(param.ty.zigTypeTag() == .Pointer or param.ty.isPtrLikeOptional())) | |
| 8825 | { | |
| 8824 | 8826 | return sema.fail(block, param_src, "non-pointer parameter declared noalias", .{}); |
| 8825 | 8827 | } |
| 8826 | 8828 | } |
test/cases/compile_errors/noalias_on_non_pointer_param.zig+6| ... | ... | @@ -1,6 +1,12 @@ |
| 1 | 1 | fn f(noalias x: i32) void { _ = x; } |
| 2 | 2 | export fn entry() void { f(1234); } |
| 3 | 3 | |
| 4 | fn generic(comptime T: type, noalias _: [*]T, noalias _: [*]const T, _: usize) void {} | |
| 5 | comptime { _ = generic; } | |
| 6 | ||
| 7 | fn slice(noalias _: []u8) void {} | |
| 8 | comptime { _ = slice; } | |
| 9 | ||
| 4 | 10 | // error |
| 5 | 11 | // backend=stage2 |
| 6 | 12 | // target=native |