aboutsummaryrefslogtreecommitdiff
path: root/src/codegen/c.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/codegen/c.zig')
-rw-r--r--src/codegen/c.zig13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/codegen/c.zig b/src/codegen/c.zig
index 97b37309b2..6a7ef2c007 100644
--- a/src/codegen/c.zig
+++ b/src/codegen/c.zig
@@ -4580,7 +4580,18 @@ fn airUnwrapErrUnionPay(f: *Function, inst: Air.Inst.Index, is_ptr: bool) !CValu
const operand_is_ptr = operand_ty.zigTypeTag() == .Pointer;
const error_union_ty = if (operand_is_ptr) operand_ty.childType() else operand_ty;
- if (!error_union_ty.errorUnionPayload().hasRuntimeBits()) return CValue.none;
+ if (!error_union_ty.errorUnionPayload().hasRuntimeBits()) {
+ if (!is_ptr) return CValue.none;
+
+ const local = try f.allocLocal(inst_ty, .Const);
+ const w = f.object.writer();
+ try w.writeAll(" = (");
+ try f.renderTypecast(w, inst_ty);
+ try w.writeByte(')');
+ try f.writeCValue(w, operand, .Initializer);
+ try w.writeAll(";\n");
+ return local;
+ }
const writer = f.object.writer();
const local = try f.allocLocal(inst_ty, .Const);