aboutsummaryrefslogtreecommitdiff
path: root/src/codegen
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2022-07-22 20:47:40 -0700
committerGitHub <noreply@github.com>2022-07-22 20:47:40 -0700
commitf591936480730a279d55a051f92806e19834faf7 (patch)
treedda39b1ee5d5e8cb1d9cc222a19188cabcb1329f /src/codegen
parenteb1b2f5c58888bfcab7e00378502f82594536aec (diff)
parent423a19fa60d2b0a11fc2fb43b12001320c2c53c5 (diff)
downloadzig-f591936480730a279d55a051f92806e19834faf7.tar.gz
zig-f591936480730a279d55a051f92806e19834faf7.zip
Merge pull request #12198 from Vexu/stage2
Sema: fix loading and storing of optional pointers represented as pointers
Diffstat (limited to 'src/codegen')
-rw-r--r--src/codegen/c.zig5
-rw-r--r--src/codegen/llvm.zig3
2 files changed, 5 insertions, 3 deletions
diff --git a/src/codegen/c.zig b/src/codegen/c.zig
index 15eb917fda..1e629d7cb0 100644
--- a/src/codegen/c.zig
+++ b/src/codegen/c.zig
@@ -3618,8 +3618,9 @@ fn airIsErr(
const operand = try f.resolveInst(un_op);
const operand_ty = f.air.typeOf(un_op);
const local = try f.allocLocal(Type.initTag(.bool), .Const);
- const payload_ty = operand_ty.errorUnionPayload();
- const error_ty = operand_ty.errorUnionSet();
+ const err_union_ty = if (is_ptr) operand_ty.childType() else operand_ty;
+ const payload_ty = err_union_ty.errorUnionPayload();
+ const error_ty = err_union_ty.errorUnionSet();
try writer.writeAll(" = ");
diff --git a/src/codegen/llvm.zig b/src/codegen/llvm.zig
index 6ebbd2aaf8..6966d8b164 100644
--- a/src/codegen/llvm.zig
+++ b/src/codegen/llvm.zig
@@ -5697,7 +5697,8 @@ pub const FuncGen = struct {
const un_op = self.air.instructions.items(.data)[inst].un_op;
const operand = try self.resolveInst(un_op);
- const err_union_ty = self.air.typeOf(un_op);
+ const operand_ty = self.air.typeOf(un_op);
+ const err_union_ty = if (operand_is_ptr) operand_ty.childType() else operand_ty;
const payload_ty = err_union_ty.errorUnionPayload();
const err_set_ty = try self.dg.lowerType(Type.initTag(.anyerror));
const zero = err_set_ty.constNull();