diff options
| author | Mitchell Hashimoto <mitchell.hashimoto@gmail.com> | 2022-03-03 17:01:31 -0800 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2022-03-03 21:33:18 -0700 |
| commit | 26be5bb8b1e1c05ceab4b7620efa2a058a174886 (patch) | |
| tree | f229afae27f08c469cb00e9c2b8d5645bfeeeaca /src | |
| parent | c9ee3c1e474a7b10fb806b60ef108057395a3cca (diff) | |
| download | zig-26be5bb8b1e1c05ceab4b7620efa2a058a174886.tar.gz zig-26be5bb8b1e1c05ceab4b7620efa2a058a174886.zip | |
stage2: peer resolve *T to [*c]T
Diffstat (limited to 'src')
| -rw-r--r-- | src/Sema.zig | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/Sema.zig b/src/Sema.zig index eb5265d404..ab9d36f3c8 100644 --- a/src/Sema.zig +++ b/src/Sema.zig @@ -18280,6 +18280,17 @@ fn resolvePeerTypes( }, .Pointer => { if (candidate_ty.ptrSize() == .C) { + // *T to [*c]T + if (chosen_ty_tag == .Pointer) { + const chosen_elem_ty = chosen_ty.childType(); + const candidate_elem_ty = candidate_ty.childType(); + if ((try sema.coerceInMemoryAllowed(block, chosen_elem_ty, candidate_elem_ty, false, target, src, src)) == .ok) { + chosen = candidate; + chosen_i = candidate_i + 1; + continue; + } + } + if (chosen_ty_tag == .Int or chosen_ty_tag == .ComptimeInt) { chosen = candidate; chosen_i = candidate_i + 1; @@ -18290,6 +18301,15 @@ fn resolvePeerTypes( } } + // [*c]T and *T + if (chosen_ty_tag == .Pointer and chosen_ty.ptrSize() == .C) { + const chosen_elem_ty = chosen_ty.childType(); + const candidate_elem_ty = candidate_ty.childType(); + if ((try sema.coerceInMemoryAllowed(block, chosen_elem_ty, candidate_elem_ty, false, target, src, src)) == .ok) { + continue; + } + } + // *[N]T to [*]T if (candidate_ty.ptrSize() == .Many and chosen_ty_tag == .Pointer and |
