Sema: fix condition for non-pointer noalias error

Closes #13987
This commit is contained in:
Veikka Tuominen 2022-12-18 00:45:07 +02:00
parent 3db8cffa3b
commit 0eddf0cbc0
2 changed files with 9 additions and 1 deletions

View File

@ -8820,7 +8820,9 @@ fn analyzeParameter(
};
return sema.failWithOwnedErrorMsg(msg);
}
if (!this_generic and is_noalias and !param.ty.isPtrAtRuntime()) {
if (!sema.is_generic_instantiation and !this_generic and is_noalias and
!(param.ty.zigTypeTag() == .Pointer or param.ty.isPtrLikeOptional()))
{
return sema.fail(block, param_src, "non-pointer parameter declared noalias", .{});
}
}

View File

@ -1,6 +1,12 @@
fn f(noalias x: i32) void { _ = x; }
export fn entry() void { f(1234); }
fn generic(comptime T: type, noalias _: [*]T, noalias _: [*]const T, _: usize) void {}
comptime { _ = generic; }
fn slice(noalias _: []u8) void {}
comptime { _ = slice; }
// error
// backend=stage2
// target=native