mirror of
https://github.com/ziglang/zig.git
synced 2024-11-15 16:45:27 +00:00
cbe: correctly handle pointers to zero bit error union payloads
This commit is contained in:
parent
4def9c4a9b
commit
1a1a5702ab
@ -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);
|
||||
|
@ -342,7 +342,6 @@ test "optional pointer to zero bit optional payload" {
|
||||
}
|
||||
|
||||
test "optional pointer to zero bit error union payload" {
|
||||
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
|
||||
|
Loading…
Reference in New Issue
Block a user