aboutsummaryrefslogtreecommitdiff
path: root/test/behavior/struct.zig
diff options
context:
space:
mode:
authorJacob Young <jacobly0@users.noreply.github.com>2022-12-26 23:13:01 -0500
committerJacob Young <jacobly0@users.noreply.github.com>2022-12-27 00:12:56 -0500
commit81318e870418d017244d6d133aabca19f2c63b58 (patch)
treecf2798c2ada2b1901f6e2129ea45c6566c40febe /test/behavior/struct.zig
parent46b49a0a766a39ca37ba48f1a1c2ed28c260b08b (diff)
downloadzig-81318e870418d017244d6d133aabca19f2c63b58.tar.gz
zig-81318e870418d017244d6d133aabca19f2c63b58.zip
llvm: add asserts and behavior tests for #14063
Closes #14063
Diffstat (limited to 'test/behavior/struct.zig')
-rw-r--r--test/behavior/struct.zig14
1 files changed, 14 insertions, 0 deletions
diff --git a/test/behavior/struct.zig b/test/behavior/struct.zig
index 2a9ea945e0..f2340091c0 100644
--- a/test/behavior/struct.zig
+++ b/test/behavior/struct.zig
@@ -1430,6 +1430,12 @@ test "struct has only one reference" {
fn errorUnionStructReturn() error{Foo}!struct { x: u8 } {
return error.Foo;
}
+
+ fn pointerPackedStruct(_: *packed struct { x: u8 }) void {}
+ fn nestedPointerPackedStruct(_: struct { x: *packed struct { x: u8 } }) void {}
+ fn pointerNestedPackedStruct(_: *struct { x: packed struct { x: u8 } }) void {}
+ fn pointerNestedPointerPackedStruct(_: *struct { x: *packed struct { x: u8 } }) void {}
+
fn optionalComptimeIntParam(comptime x: ?comptime_int) comptime_int {
return x.?;
}
@@ -1446,6 +1452,14 @@ test "struct has only one reference" {
const error_union_struct_return: *const anyopaque = &S.errorUnionStructReturn;
try expect(optional_struct_return != error_union_struct_return);
+ const pointer_packed_struct: *const anyopaque = &S.pointerPackedStruct;
+ const nested_pointer_packed_struct: *const anyopaque = &S.nestedPointerPackedStruct;
+ try expect(pointer_packed_struct != nested_pointer_packed_struct);
+
+ const pointer_nested_packed_struct: *const anyopaque = &S.pointerNestedPackedStruct;
+ const pointer_nested_pointer_packed_struct: *const anyopaque = &S.pointerNestedPointerPackedStruct;
+ try expect(pointer_nested_packed_struct != pointer_nested_pointer_packed_struct);
+
try expectEqual(@alignOf(struct {}), S.optionalComptimeIntParam(@alignOf(struct {})));
try expectEqual(@alignOf(struct { x: u8 }), S.errorUnionComptimeIntParam(@alignOf(struct { x: u8 })));
try expectEqual(@sizeOf(struct { x: u16 }), S.optionalComptimeIntParam(@sizeOf(struct { x: u16 })));