From dca17d3603e5b68a8f683bfc1bdabc9959654d26 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Wed, 20 Sep 2023 19:40:21 -0700 Subject: Sema: fix struct alignment regressions --- src/InternPool.zig | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'src/InternPool.zig') diff --git a/src/InternPool.zig b/src/InternPool.zig index 03eb5994d5..b7d79d6c29 100644 --- a/src/InternPool.zig +++ b/src/InternPool.zig @@ -536,6 +536,19 @@ pub const Key = union(enum) { s.flagsPtr(ip).layout_wip = false; } + pub fn setAlignmentWip(s: @This(), ip: *InternPool) bool { + if (s.layout == .Packed) return false; + const flags_ptr = s.flagsPtr(ip); + if (flags_ptr.alignment_wip) return true; + flags_ptr.alignment_wip = true; + return false; + } + + pub fn clearAlignmentWip(s: @This(), ip: *InternPool) void { + if (s.layout == .Packed) return; + s.flagsPtr(ip).alignment_wip = false; + } + pub fn setFullyResolved(s: @This(), ip: *InternPool) bool { if (s.layout == .Packed) return true; const flags_ptr = s.flagsPtr(ip); @@ -2971,6 +2984,8 @@ pub const Tag = enum(u8) { any_aligned_fields: bool, /// `undefined` until the layout_resolved alignment: Alignment, + /// Dependency loop detection when resolving struct alignment. + alignment_wip: bool, /// Dependency loop detection when resolving field types. field_types_wip: bool, /// Dependency loop detection when resolving struct layout. @@ -2982,7 +2997,7 @@ pub const Tag = enum(u8) { // which `layout_resolved` does not ensure. fully_resolved: bool, - _: u12 = 0, + _: u11 = 0, }; }; }; @@ -5300,6 +5315,7 @@ pub fn getStructType( .any_default_inits = ini.any_default_inits, .any_aligned_fields = ini.any_aligned_fields, .alignment = .none, + .alignment_wip = false, .field_types_wip = false, .layout_wip = false, .layout_resolved = false, -- cgit v1.2.3