aboutsummaryrefslogtreecommitdiff
path: root/test/behavior/struct.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2023-01-16 21:19:48 -0500
committerGitHub <noreply@github.com>2023-01-16 21:19:48 -0500
commite646becd04c37fbaaa654f6419dd9f5e85d9f210 (patch)
tree01e5a1535ebec3ab5d2476396efb9469d75f29ce /test/behavior/struct.zig
parent37424fd11a79801e18a121ee7e86730012b0c55e (diff)
parentb2c85464bef931c8263b50b40697a584600ee69e (diff)
downloadzig-e646becd04c37fbaaa654f6419dd9f5e85d9f210.tar.gz
zig-e646becd04c37fbaaa654f6419dd9f5e85d9f210.zip
Merge pull request #14336 from Vexu/field-reorder
Sema: automatically optimize order of struct fields
Diffstat (limited to 'test/behavior/struct.zig')
-rw-r--r--test/behavior/struct.zig18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/behavior/struct.zig b/test/behavior/struct.zig
index 20a09f92cc..a32a0ed495 100644
--- a/test/behavior/struct.zig
+++ b/test/behavior/struct.zig
@@ -1555,3 +1555,21 @@ test "optional generic function label struct field" {
};
try expect((Options{}).isFoo.?(u8) == 123);
}
+
+test "struct fields get automatically reordered" {
+ if (builtin.zig_backend != .stage2_llvm) return error.SkipZigTest; // TODO
+
+ const S1 = struct {
+ a: u32,
+ b: u32,
+ c: bool,
+ d: bool,
+ };
+ const S2 = struct {
+ a: u32,
+ b: bool,
+ c: u32,
+ d: bool,
+ };
+ try expect(@sizeOf(S1) == @sizeOf(S2));
+}