diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2022-01-25 14:53:41 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2022-01-25 14:53:41 -0700 |
| commit | ef7eff393912cae322fbc755536bc060c0166b94 (patch) | |
| tree | a9c6d4ca180644cb85a048673c7583708d6e4b69 /src | |
| parent | f2835c6a286c9e6bb033cbf04a2ed3463e206bf3 (diff) | |
| download | zig-ef7eff393912cae322fbc755536bc060c0166b94.tar.gz zig-ef7eff393912cae322fbc755536bc060c0166b94.zip | |
Sema: coercion of pointers to C pointers
Diffstat (limited to 'src')
| -rw-r--r-- | src/Sema.zig | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/Sema.zig b/src/Sema.zig index a761623b2e..6fc4f85174 100644 --- a/src/Sema.zig +++ b/src/Sema.zig @@ -14014,6 +14014,23 @@ fn coerce( const addr = try sema.coerce(block, ptr_size_ty, inst, inst_src); return sema.coerceCompatiblePtrs(block, dest_ty, addr, inst_src); }, + .Pointer => p: { + const inst_info = inst_ty.ptrInfo().data; + if (inst_info.size == .Slice) break :p; + switch (try sema.coerceInMemoryAllowed( + block, + dest_info.pointee_type, + inst_info.pointee_type, + dest_info.mutable, + target, + dest_ty_src, + inst_src, + )) { + .ok => {}, + .no_match => break :p, + } + return sema.coerceCompatiblePtrs(block, dest_ty, inst, inst_src); + }, else => {}, } } |
