| author | |
| committer | |
| log | 6f250f568a5d5dd667b9f290ed8afc9412175b1d |
| tree | 38eb7603a54d2dac1db55d833ef4f706fa41531e |
| parent | 844e05f619d62c1c2a332c1effa3ab6c211b3062 |
See #3022 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 | } |
| 16 | 15 | ||
| ... | @@ -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 | }; |
| 32 | const FooNoVoid = enum { | ||
| 33 | One: i32, | ||
| 34 | Two: Point, | ||
| 35 | }; | ||
| 33 | const Bar = enum { | 36 | const Bar = enum { |
| 34 | A, | 37 | A, |
| 35 | B, | 38 | B, |
test/cases/struct.zig+7-1| ... | @@ -1,4 +1,5 @@ | ... | @@ -1,4 +1,5 @@ |
| 1 | const assert = @import("std").debug.assert; | 1 | const assert = @import("std").debug.assert; |
| 2 | const builtin = @import("builtin"); | ||
| 2 | 3 | ||
| 3 | const StructWithNoFields = struct { | 4 | const 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 | } |
| 259 | 260 | ||
| 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, |