| ... | ... | @@ -520,6 +520,8 @@ TypeTableEntry *get_array_type(CodeGen *g, TypeTableEntry *child_type, uint64_t |
| 520 | 520 | TypeTableEntry *entry = existing_entry->value; |
| 521 | 521 | return entry; |
| 522 | 522 | } else { |
| 523 | ensure_complete_type(g, child_type); |
| 524 | |
| 523 | 525 | TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdArray); |
| 524 | 526 | entry->zero_bits = (array_size == 0) || child_type->zero_bits; |
| 525 | 527 | |
| ... | ... | @@ -1080,6 +1082,23 @@ static TypeTableEntry *analyze_fn_type(CodeGen *g, AstNode *proto_node, Scope *c |
| 1080 | 1082 | return get_fn_type(g, &fn_type_id); |
| 1081 | 1083 | } |
| 1082 | 1084 | |
| 1085 | static bool type_is_invalid(TypeTableEntry *type_entry) { |
| 1086 | switch (type_entry->id) { |
| 1087 | case TypeTableEntryIdInvalid: |
| 1088 | return true; |
| 1089 | case TypeTableEntryIdStruct: |
| 1090 | return type_entry->data.structure.is_invalid; |
| 1091 | case TypeTableEntryIdEnum: |
| 1092 | return type_entry->data.enumeration.is_invalid; |
| 1093 | case TypeTableEntryIdUnion: |
| 1094 | return type_entry->data.unionation.is_invalid; |
| 1095 | default: |
| 1096 | return false; |
| 1097 | } |
| 1098 | zig_unreachable(); |
| 1099 | } |
| 1100 | |
| 1101 | |
| 1083 | 1102 | static TypeTableEntry *create_enum_tag_type(CodeGen *g, TypeTableEntry *enum_type, TypeTableEntry *int_type) { |
| 1084 | 1103 | TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdEnumTag); |
| 1085 | 1104 | |
| ... | ... | @@ -1296,7 +1315,7 @@ static void resolve_struct_type(CodeGen *g, TypeTableEntry *struct_type) { |
| 1296 | 1315 | } |
| 1297 | 1316 | |
| 1298 | 1317 | assert(!struct_type->data.structure.zero_bits_loop_flag); |
| 1299 | | assert(struct_type->data.enumeration.fields); |
| 1318 | assert(struct_type->data.structure.fields); |
| 1300 | 1319 | assert(decl_node->type == NodeTypeContainerDecl); |
| 1301 | 1320 | |
| 1302 | 1321 | size_t field_count = struct_type->data.structure.src_field_count; |
| ... | ... | @@ -1309,13 +1328,14 @@ static void resolve_struct_type(CodeGen *g, TypeTableEntry *struct_type) { |
| 1309 | 1328 | |
| 1310 | 1329 | Scope *scope = &struct_type->data.structure.decls_scope->base; |
| 1311 | 1330 | |
| 1331 | //if (buf_eql_str(&struct_type->name, "Particle")) { BREAKPOINT; } |
| 1312 | 1332 | for (size_t i = 0; i < field_count; i += 1) { |
| 1313 | 1333 | TypeStructField *type_struct_field = &struct_type->data.structure.fields[i]; |
| 1314 | 1334 | TypeTableEntry *field_type = type_struct_field->type_entry; |
| 1315 | 1335 | |
| 1316 | 1336 | ensure_complete_type(g, field_type); |
| 1317 | | if (field_type->id == TypeTableEntryIdInvalid) { |
| 1318 | | struct_type->data.enumeration.is_invalid = true; |
| 1337 | if (type_is_invalid(field_type)) { |
| 1338 | struct_type->data.structure.is_invalid = true; |
| 1319 | 1339 | continue; |
| 1320 | 1340 | } |
| 1321 | 1341 | |
| ... | ... | @@ -1342,6 +1362,7 @@ static void resolve_struct_type(CodeGen *g, TypeTableEntry *struct_type) { |
| 1342 | 1362 | assert(struct_type->di_type); |
| 1343 | 1363 | |
| 1344 | 1364 | LLVMStructSetBody(struct_type->type_ref, element_types, gen_field_count, false); |
| 1365 | assert(LLVMStoreSizeOfType(g->target_data_ref, struct_type->type_ref) > 0); |
| 1345 | 1366 | |
| 1346 | 1367 | ZigLLVMDIType **di_element_types = allocate<ZigLLVMDIType*>(gen_field_count); |
| 1347 | 1368 | |
| ... | ... | @@ -1492,7 +1513,7 @@ static void resolve_struct_zero_bits(CodeGen *g, TypeTableEntry *struct_type) { |
| 1492 | 1513 | type_struct_field->gen_index = SIZE_MAX; |
| 1493 | 1514 | |
| 1494 | 1515 | type_ensure_zero_bits_known(g, field_type); |
| 1495 | | if (field_type->id == TypeTableEntryIdInvalid) { |
| 1516 | if (type_is_invalid(field_type)) { |
| 1496 | 1517 | struct_type->data.structure.is_invalid = true; |
| 1497 | 1518 | continue; |
| 1498 | 1519 | } |