| ... | @@ -771,21 +771,25 @@ pub const DeclGen = struct { | ... | @@ -771,21 +771,25 @@ pub const DeclGen = struct { |
| 771 | return try self.constructArray(result_ty_ref, constituents); | 771 | return try self.constructArray(result_ty_ref, constituents); |
| 772 | }, | 772 | }, |
| 773 | .struct_type => { | 773 | .struct_type => { |
| 774 | const struct_ty = mod.typeToStruct(ty).?; | 774 | const struct_type = mod.typeToStruct(ty).?; |
| 775 | if (struct_ty.layout == .Packed) { | 775 | if (struct_type.layout == .Packed) { |
| 776 | return self.todo("packed struct constants", .{}); | 776 | return self.todo("packed struct constants", .{}); |
| 777 | } | 777 | } |
| 778 | | 778 | |
| 779 | var constituents = std.ArrayList(IdRef).init(self.gpa); | 779 | var constituents = std.ArrayList(IdRef).init(self.gpa); |
| 780 | defer constituents.deinit(); | 780 | defer constituents.deinit(); |
| 781 | | 781 | |
| 782 | var field_it = struct_ty.runtimeFieldIterator(mod); | 782 | var it = struct_type.iterateRuntimeOrder(ip); |
| 783 | while (field_it.next()) |field_and_index| { | 783 | while (it.next()) |field_index| { |
| 784 | const field = field_and_index.field; | 784 | const field_ty = struct_type.field_types.get(ip)[field_index].toType(); |
| 785 | const index = field_and_index.index; | 785 | if (!field_ty.hasRuntimeBitsIgnoreComptime(mod)) { |
| | 786 | // This is a zero-bit field - we only needed it for the alignment. |
| | 787 | continue; |
| | 788 | } |
| | 789 | |
| 786 | // TODO: Padding? | 790 | // TODO: Padding? |
| 787 | const field_val = try val.fieldValue(mod, index); | 791 | const field_val = try val.fieldValue(mod, field_index); |
| 788 | const field_id = try self.constant(field.ty, field_val, .indirect); | 792 | const field_id = try self.constant(field_ty, field_val, .indirect); |
| 789 | | 793 | |
| 790 | try constituents.append(field_id); | 794 | try constituents.append(field_id); |
| 791 | } | 795 | } |