zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit f47cf93b477c47cb4be00019203b2cd11a94d53d (tree)
parent 9c652cc6507e6cba9bba5403bd819676f23c93a1
Author: Andrew Kelley <andrew@ziglang.org>
Date:   Tue, 20 Jul 2021 15:56:42 -0700

stage2: C backend: fix ret AIR instruction

when operand has 0 runtime bits

Diffstat:
Msrc/codegen/c.zig | 12++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/src/codegen/c.zig b/src/codegen/c.zig @@ -1006,11 +1006,15 @@ fn airLoad(o: *Object, inst: Air.Inst.Index) !CValue { fn airRet(o: *Object, inst: Air.Inst.Index) !CValue { const un_op = o.air.instructions.items(.data)[inst].un_op; - const operand = try o.resolveInst(un_op); const writer = o.writer(); - try writer.writeAll("return "); - try o.writeCValue(writer, operand); - try writer.writeAll(";\n"); + if (o.air.typeOf(un_op).hasCodeGenBits()) { + const operand = try o.resolveInst(un_op); + try writer.writeAll("return "); + try o.writeCValue(writer, operand); + try writer.writeAll(";\n"); + } else { + try writer.writeAll("return;\n"); + } return CValue.none; }