aboutsummaryrefslogtreecommitdiff
path: root/test/behavior/struct.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2022-05-02 14:59:31 -0700
committerAndrew Kelley <andrew@ziglang.org>2022-05-02 22:06:02 -0700
commitd98869da430b0ab7054600dd0cb80a6d45ce0639 (patch)
tree49a1cfba9e30ba4052ccb5d6585ed4d76ed676f3 /test/behavior/struct.zig
parent1a1f62a0ce0565a7f6da9b4b8654407f6c514cb0 (diff)
downloadzig-d98869da430b0ab7054600dd0cb80a6d45ce0639.tar.gz
zig-d98869da430b0ab7054600dd0cb80a6d45ce0639.zip
behavior tests: fix wrong packed struct test case
Packed structs are defined to have the same alignment and size as their backing integer.
Diffstat (limited to 'test/behavior/struct.zig')
-rw-r--r--test/behavior/struct.zig19
1 files changed, 4 insertions, 15 deletions
diff --git a/test/behavior/struct.zig b/test/behavior/struct.zig
index 89f6e20aa0..b05126db62 100644
--- a/test/behavior/struct.zig
+++ b/test/behavior/struct.zig
@@ -421,21 +421,10 @@ test "packed struct 24bits" {
if (builtin.cpu.arch == .arm) return error.SkipZigTest; // TODO
comptime {
- // TODO Remove if and leave only the else branch when it is also fixed in stage2
- if (builtin.zig_backend == .stage2_llvm or builtin.zig_backend == .stage2_x86 or
- builtin.zig_backend == .stage2_riscv64)
- {
- // Stage 2 still expects the wrong values
- try expect(@sizeOf(Foo24Bits) == 4);
- if (@sizeOf(usize) == 4) {
- try expect(@sizeOf(Foo96Bits) == 12);
- } else {
- try expect(@sizeOf(Foo96Bits) == 16);
- }
- } else {
- // Stage1 is now fixed and is expected to return right values
- try expectEqual(@sizeOf(Foo24Bits), 3);
- try expectEqual(@sizeOf(Foo96Bits), 12);
+ // stage1 gets the wrong answer for sizeof
+ if (builtin.zig_backend != .stage1) {
+ std.debug.assert(@sizeOf(Foo24Bits) == @sizeOf(u24));
+ std.debug.assert(@sizeOf(Foo96Bits) == @sizeOf(u96));
}
}