diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2022-03-27 14:21:32 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2022-03-27 14:22:47 -0700 |
| commit | 6d2ec7a4e39e3464bb5f14747937df9544e89ee7 (patch) | |
| tree | 2fe3eaaef62f7cc9fb3c52aec6d7acf707786281 /test/behavior | |
| parent | 052079c99455d01312d377d72fa1b8b5c0b22aad (diff) | |
| download | zig-6d2ec7a4e39e3464bb5f14747937df9544e89ee7.tar.gz zig-6d2ec7a4e39e3464bb5f14747937df9544e89ee7.zip | |
LLVM: handle aggregate_init for packed structs
Diffstat (limited to 'test/behavior')
| -rw-r--r-- | test/behavior/struct.zig | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/test/behavior/struct.zig b/test/behavior/struct.zig index 4bed1f56cc..a46605c424 100644 --- a/test/behavior/struct.zig +++ b/test/behavior/struct.zig @@ -1294,3 +1294,24 @@ test "loading a struct pointer perfoms a copy" { try expect(s2.b == 2); try expect(s2.c == 3); } + +test "packed struct aggregate init" { + if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO + if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO + if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO + if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO + if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO + + const S = struct { + fn foo(a: i2, b: i6) u8 { + return @bitCast(u8, P{ .a = a, .b = b }); + } + + const P = packed struct { + a: i2, + b: i6, + }; + }; + const result = @bitCast(u8, S.foo(1, 2)); + try expect(result == 9); +} |
