zig

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

commit 7a85ad151daece3d0bba3c8d23081502a0956c95 (tree)
parent 51f6438e076c0347197c251716174037a8465e91
Author: mlugg <mlugg@mlugg.co.uk>
Date:   Sat, 19 Aug 2023 02:35:00 +0100

cbe: elide block result allocation for 0-bit types

This logic already existed for the void type, but is also necessary for
other 0-bit types. Without it, we try to alloc a local for a 0-bit type
which gets translated to a local of type `void` which C doesn't like.

Diffstat:
Msrc/codegen/c.zig | 2+-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/codegen/c.zig b/src/codegen/c.zig @@ -4285,7 +4285,7 @@ fn airBlock(f: *Function, inst: Air.Inst.Index) !CValue { const writer = f.object.writer(); const inst_ty = f.typeOfIndex(inst); - const result = if (inst_ty.ip_index != .void_type and !f.liveness.isUnused(inst)) + const result = if (inst_ty.hasRuntimeBitsIgnoreComptime(mod) and !f.liveness.isUnused(inst)) try f.allocLocal(inst, inst_ty) else .none;