authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-09-30 23:42:44-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-09-30 23:42:44-04:00
log6f250f568a5d5dd667b9f290ed8afc9412175b1d
tree38eb7603a54d2dac1db55d833ef4f706fa41531e
parent844e05f619d62c1c2a332c1effa3ab6c211b3062

workaround llvm bug for windows alignment

See #302

2 files changed, 12 insertions(+), 3 deletions(-)

test/cases/enum.zig+5-2
......@@ -9,8 +9,7 @@ test "enum type" {
99 assert(bar == Bar.B);
1010 assert(@memberCount(Foo) == 3);
1111 assert(@memberCount(Bar) == 4);
12 const expected_foo_size = 16 + @sizeOf(usize);
13 assert(@sizeOf(Foo) == expected_foo_size);
12 assert(@sizeOf(Foo) == @sizeOf(FooNoVoid));
1413 assert(@sizeOf(Bar) == 1);
1514}
1615
......@@ -30,6 +29,10 @@ const Foo = enum {
3029 Two: Point,
3130 Three: void,
3231};
32const FooNoVoid = enum {
33 One: i32,
34 Two: Point,
35};
3336const Bar = enum {
3437 A,
3538 B,
test/cases/struct.zig+7-1
......@@ -1,4 +1,5 @@
11const assert = @import("std").debug.assert;
2const builtin = @import("builtin");
23
34const StructWithNoFields = struct {
45 fn add(a: i32, b: i32) -> i32 { a + b }
......@@ -257,7 +258,12 @@ test "packed struct 24bits" {
257258 assert(@sizeOf(Foo96Bits) == 12);
258259 }
259260
260 var value = Foo96Bits {
261 // TODO workaround for LLVM bug on windows
262 // http://lists.llvm.org/pipermail/llvm-dev/2017-September/117864.html
263 const align_bytes = if (builtin.os == builtin.Os.windows and
264 builtin.arch == builtin.Arch.x86_64) 32 else @alignOf(Foo96Bits);
265
266 var value align(align_bytes) = Foo96Bits {
261267 .a = 0,
262268 .b = 0,
263269 .c = 0,