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" {...@@ -9,8 +9,7 @@ test "enum type" {
9 assert(bar == Bar.B);9 assert(bar == Bar.B);
10 assert(@memberCount(Foo) == 3);10 assert(@memberCount(Foo) == 3);
11 assert(@memberCount(Bar) == 4);11 assert(@memberCount(Bar) == 4);
12 const expected_foo_size = 16 + @sizeOf(usize);12 assert(@sizeOf(Foo) == @sizeOf(FooNoVoid));
13 assert(@sizeOf(Foo) == expected_foo_size);
14 assert(@sizeOf(Bar) == 1);13 assert(@sizeOf(Bar) == 1);
15}14}
1615
...@@ -30,6 +29,10 @@ const Foo = enum {...@@ -30,6 +29,10 @@ const Foo = enum {
30 Two: Point,29 Two: Point,
31 Three: void,30 Three: void,
32};31};
32const FooNoVoid = enum {
33 One: i32,
34 Two: Point,
35};
33const Bar = enum {36const Bar = enum {
34 A,37 A,
35 B,38 B,
test/cases/struct.zig+7-1
...@@ -1,4 +1,5 @@...@@ -1,4 +1,5 @@
1const assert = @import("std").debug.assert;1const assert = @import("std").debug.assert;
2const builtin = @import("builtin");
23
3const StructWithNoFields = struct {4const StructWithNoFields = struct {
4 fn add(a: i32, b: i32) -> i32 { a + b }5 fn add(a: i32, b: i32) -> i32 { a + b }
...@@ -257,7 +258,12 @@ test "packed struct 24bits" {...@@ -257,7 +258,12 @@ test "packed struct 24bits" {
257 assert(@sizeOf(Foo96Bits) == 12);258 assert(@sizeOf(Foo96Bits) == 12);
258 }259 }
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 {
261 .a = 0,267 .a = 0,
262 .b = 0,268 .b = 0,
263 .c = 0,269 .c = 0,