authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-04-02 18:30:53-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-04-02 18:31:19-04:00
loge9dc504141a18e315fe547c54885811927608319
treeb1940240dafef313ff688e65ffd6c830912be4e4
parentd577dde636173e5ec799e67ead32722ac59148db
signature Commit is signed but in an unrecognized format.

avoid tripping assertion for setting struct body twice


1 files changed, 11 insertions(+), 0 deletions(-)

src/analyze.cpp+11
...@@ -6443,6 +6443,16 @@ static void resolve_llvm_types_struct(CodeGen *g, ZigType *struct_type, ResolveS...@@ -6443,6 +6443,16 @@ static void resolve_llvm_types_struct(CodeGen *g, ZigType *struct_type, ResolveS
6443 size_t first_packed_bits_offset_misalign = SIZE_MAX;6443 size_t first_packed_bits_offset_misalign = SIZE_MAX;
6444 size_t debug_field_count = 0;6444 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
6446 for (size_t i = 0; i < field_count; i += 1) {6456 for (size_t i = 0; i < field_count; i += 1) {
6447 TypeStructField *type_struct_field = &struct_type->data.structure.fields[i];6457 TypeStructField *type_struct_field = &struct_type->data.structure.fields[i];
6448 ZigType *field_type = type_struct_field->type_entry;6458 ZigType *field_type = type_struct_field->type_entry;
...@@ -6661,6 +6671,7 @@ static void resolve_llvm_types_union(CodeGen *g, ZigType *union_type, ResolveSta...@@ -6661,6 +6671,7 @@ static void resolve_llvm_types_union(CodeGen *g, ZigType *union_type, ResolveSta
66616671
6662 size_t padding_bytes = union_type->data.unionation.union_abi_size - most_aligned_union_member->abi_size;6672 size_t padding_bytes = union_type->data.unionation.union_abi_size - most_aligned_union_member->abi_size;
6663 (void)get_llvm_type(g, most_aligned_union_member);6673 (void)get_llvm_type(g, most_aligned_union_member);
6674 if (union_type->data.unionation.resolve_status >= wanted_resolve_status) return;
6664 if (padding_bytes > 0) {6675 if (padding_bytes > 0) {
6665 ZigType *u8_type = get_int_type(g, false, 8);6676 ZigType *u8_type = get_int_type(g, false, 8);
6666 ZigType *padding_array = get_array_type(g, u8_type, padding_bytes);6677 ZigType *padding_array = get_array_type(g, u8_type, padding_bytes);