diff options
| author | Veikka Tuominen <git@vexu.eu> | 2023-03-20 18:05:52 +0200 |
|---|---|---|
| committer | Veikka Tuominen <git@vexu.eu> | 2023-03-21 00:34:12 +0200 |
| commit | 773b1c4c5cdf9fde19cbf09d0f81f1bfe27ed7ca (patch) | |
| tree | 61c419ac3a8f30d31ad1f6190ca7b7a08af2f249 /test | |
| parent | 0c169127338ef8af752d1a077e412b5135e300d5 (diff) | |
| download | zig-773b1c4c5cdf9fde19cbf09d0f81f1bfe27ed7ca.tar.gz zig-773b1c4c5cdf9fde19cbf09d0f81f1bfe27ed7ca.zip | |
llvm: fix lowering packed union initiated to zero-bit value
Closes #14980
Diffstat (limited to 'test')
| -rw-r--r-- | test/behavior/union.zig | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/behavior/union.zig b/test/behavior/union.zig index 9b49f8bf47..ff3f0b7e54 100644 --- a/test/behavior/union.zig +++ b/test/behavior/union.zig @@ -1493,3 +1493,23 @@ test "union reassignment can use previous value" { a = U{ .b = a.a }; try expect(a.b == 32); } + +test "packed union with zero-bit field" { + if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO + if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO + if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO + if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO + + const S = packed struct { + nested: packed union { + zero: void, + sized: u32, + }, + bar: u32, + + fn doTest(self: @This()) !void { + try expect(self.bar == 42); + } + }; + try S.doTest(.{ .nested = .{ .zero = {} }, .bar = 42 }); +} |
