codegen: fix union padding

This regressed during the internpool merges. This commit
reinstates the padding logic for unions.
This commit is contained in:
Luuk de Gram 2023-06-14 20:03:01 +02:00
parent 098b0b50ab
commit 1cfad29f10
No known key found for this signature in database
GPG Key ID: A8CFE58E4DC7D664
2 changed files with 4 additions and 1 deletions

View File

@ -598,6 +598,10 @@ pub fn generateSymbol(
.fail => |em| return Result{ .fail = em },
}
}
if (layout.padding > 0) {
try code.writer().writeByteNTimes(0, layout.padding);
}
},
.memoized_call => unreachable,
}

View File

@ -17,7 +17,6 @@ test "union that needs padding bytes inside an array" {
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest;
var as = [_]A{
A{ .B = B{ .D = 1 } },