aboutsummaryrefslogtreecommitdiff
path: root/src/Sema.zig
diff options
context:
space:
mode:
authorRobin Voetter <robin@voetter.nl>2021-10-26 02:28:02 +0200
committerRobin Voetter <robin@voetter.nl>2021-10-26 02:28:02 +0200
commit914993123c91534e4fa1d32c93bc43341cb24a8c (patch)
treea22b86f02a19d8a2d388a23126b59ce5d4df7307 /src/Sema.zig
parentdf198ea60e05664b5b72a43aae815fa06d94c19c (diff)
downloadzig-914993123c91534e4fa1d32c93bc43341cb24a8c.tar.gz
zig-914993123c91534e4fa1d32c93bc43341cb24a8c.zip
stage2: return proper pointer for c pointer orelse
Diffstat (limited to 'src/Sema.zig')
-rw-r--r--src/Sema.zig11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/Sema.zig b/src/Sema.zig
index 2562948e8e..924ff7b267 100644
--- a/src/Sema.zig
+++ b/src/Sema.zig
@@ -4666,7 +4666,16 @@ fn zirOptionalPayload(
if (operand_ty.ptrSize() != .C) {
return sema.failWithExpectedOptionalType(block, src, operand_ty);
}
- break :t operand_ty;
+ const ptr_info = operand_ty.ptrInfo().data;
+ break :t try Type.ptr(sema.arena, .{
+ .pointee_type = try ptr_info.pointee_type.copy(sema.arena),
+ .@"align" = ptr_info.@"align",
+ .@"addrspace" = ptr_info.@"addrspace",
+ .mutable = ptr_info.mutable,
+ .@"allowzero" = ptr_info.@"allowzero",
+ .@"volatile" = ptr_info.@"volatile",
+ .size = .One,
+ });
},
else => return sema.failWithExpectedOptionalType(block, src, operand_ty),
};