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