Skip to content

Commit e9dc504

Browse files
committed
avoid tripping assertion for setting struct body twice
1 parent d577dde commit e9dc504

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/analyze.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6443,6 +6443,16 @@ static void resolve_llvm_types_struct(CodeGen *g, ZigType *struct_type, ResolveS
64436443
size_t first_packed_bits_offset_misalign = SIZE_MAX;
64446444
size_t debug_field_count = 0;
64456445

6446+
// trigger all the recursive get_llvm_type calls
6447+
for (size_t i = 0; i < field_count; i += 1) {
6448+
TypeStructField *type_struct_field = &struct_type->data.structure.fields[i];
6449+
ZigType *field_type = type_struct_field->type_entry;
6450+
if (!type_has_bits(field_type))
6451+
continue;
6452+
(void)get_llvm_type(g, field_type);
6453+
if (struct_type->data.structure.resolve_status >= wanted_resolve_status) return;
6454+
}
6455+
64466456
for (size_t i = 0; i < field_count; i += 1) {
64476457
TypeStructField *type_struct_field = &struct_type->data.structure.fields[i];
64486458
ZigType *field_type = type_struct_field->type_entry;
@@ -6661,6 +6671,7 @@ static void resolve_llvm_types_union(CodeGen *g, ZigType *union_type, ResolveSta
66616671

66626672
size_t padding_bytes = union_type->data.unionation.union_abi_size - most_aligned_union_member->abi_size;
66636673
(void)get_llvm_type(g, most_aligned_union_member);
6674+
if (union_type->data.unionation.resolve_status >= wanted_resolve_status) return;
66646675
if (padding_bytes > 0) {
66656676
ZigType *u8_type = get_int_type(g, false, 8);
66666677
ZigType *padding_array = get_array_type(g, u8_type, padding_bytes);

0 commit comments

Comments
 (0)