diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2019-04-02 18:30:53 -0400 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2019-04-02 18:31:19 -0400 |
| commit | e9dc504141a18e315fe547c54885811927608319 (patch) | |
| tree | b1940240dafef313ff688e65ffd6c830912be4e4 /src/analyze.cpp | |
| parent | d577dde636173e5ec799e67ead32722ac59148db (diff) | |
| download | zig-e9dc504141a18e315fe547c54885811927608319.tar.gz zig-e9dc504141a18e315fe547c54885811927608319.zip | |
avoid tripping assertion for setting struct body twice
Diffstat (limited to 'src/analyze.cpp')
| -rw-r--r-- | src/analyze.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/analyze.cpp b/src/analyze.cpp index 614f907f70..ea31717ca2 100644 --- a/src/analyze.cpp +++ b/src/analyze.cpp @@ -6443,6 +6443,16 @@ static void resolve_llvm_types_struct(CodeGen *g, ZigType *struct_type, ResolveS size_t first_packed_bits_offset_misalign = SIZE_MAX; size_t debug_field_count = 0; + // trigger all the recursive get_llvm_type calls + for (size_t i = 0; i < field_count; i += 1) { + TypeStructField *type_struct_field = &struct_type->data.structure.fields[i]; + ZigType *field_type = type_struct_field->type_entry; + if (!type_has_bits(field_type)) + continue; + (void)get_llvm_type(g, field_type); + if (struct_type->data.structure.resolve_status >= wanted_resolve_status) return; + } + for (size_t i = 0; i < field_count; i += 1) { TypeStructField *type_struct_field = &struct_type->data.structure.fields[i]; ZigType *field_type = type_struct_field->type_entry; @@ -6661,6 +6671,7 @@ static void resolve_llvm_types_union(CodeGen *g, ZigType *union_type, ResolveSta size_t padding_bytes = union_type->data.unionation.union_abi_size - most_aligned_union_member->abi_size; (void)get_llvm_type(g, most_aligned_union_member); + if (union_type->data.unionation.resolve_status >= wanted_resolve_status) return; if (padding_bytes > 0) { ZigType *u8_type = get_int_type(g, false, 8); ZigType *padding_array = get_array_type(g, u8_type, padding_bytes); |
