diff options
| author | LemonBoy <thatlemon@gmail.com> | 2019-09-07 11:17:12 +0200 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2019-09-10 10:07:32 -0400 |
| commit | 8fbae77770a77ccd645054e06baab45b03c8befd (patch) | |
| tree | 274683fbf2812e735de6cc7228430f2f50d4ad12 /test | |
| parent | a06f84fcc62396dc4216d5c9f8da1f0463d17f50 (diff) | |
| download | zig-8fbae77770a77ccd645054e06baab45b03c8befd.tar.gz zig-8fbae77770a77ccd645054e06baab45b03c8befd.zip | |
Force LLVM to generate byte-aligned packed unions
Sometimes the frontend and LLVM would disagree on the ABI alignment of a
packed union. Solve the problem by telling LLVM we're gonna manage the
struct layout by ourselves.
Closes #3184
Diffstat (limited to 'test')
| -rw-r--r-- | test/stage1/behavior/union.zig | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/test/stage1/behavior/union.zig b/test/stage1/behavior/union.zig index 7c5c653275..21308b0ea2 100644 --- a/test/stage1/behavior/union.zig +++ b/test/stage1/behavior/union.zig @@ -482,3 +482,15 @@ test "comparison between union and enum literal" { testComparison(); comptime testComparison(); } + +test "packed union generates correctly aligned LLVM type" { + const U = packed union { + f1: fn () void, + f2: u32, + }; + var foo = [_]U{ + U{ .f1 = doTest }, + U{ .f2 = 0 }, + }; + foo[0].f1(); +} |
