Value: ensure that extern structs have their layout resolved in ptrField

This commit is contained in:
kcbanner
2025-03-09 15:44:26 -04:00
committed by Andrew Kelley
parent 90084f4ae3
commit fa59153896
2 changed files with 29 additions and 0 deletions

View File

@@ -3013,6 +3013,7 @@ pub fn ptrField(parent_ptr: Value, field_idx: u32, pt: Zcu.PerThread) !Value {
.auto => break :field .{ field_ty, try aggregate_ty.fieldAlignmentSema(field_idx, pt) },
.@"extern" => {
// Well-defined layout, so just offset the pointer appropriately.
try aggregate_ty.resolveLayout(pt);
const byte_off = aggregate_ty.structFieldOffset(field_idx, zcu);
const field_align = a: {
const parent_align = if (parent_ptr_info.flags.alignment == .none) pa: {