| ... | ... | @@ -264,6 +264,7 @@ static IrInstruction *ir_analyze_inferred_field_ptr(IrAnalyze *ira, Buf *field_n |
| 264 | 264 | IrInstruction *source_instr, IrInstruction *container_ptr, ZigType *container_type); |
| 265 | 265 | static ResultLoc *no_result_loc(void); |
| 266 | 266 | static IrInstruction *ir_analyze_test_non_null(IrAnalyze *ira, IrInstruction *source_inst, IrInstruction *value); |
| 267 | static IrInstruction *ir_error_dependency_loop(IrAnalyze *ira, IrInstruction *source_instr); |
| 267 | 268 | |
| 268 | 269 | static void destroy_instruction(IrInstruction *inst) { |
| 269 | 270 | #ifdef ZIG_ENABLE_MEM_PROFILE |
| ... | ... | @@ -20022,8 +20023,13 @@ static IrInstruction *ir_analyze_container_member_access_inner(IrAnalyze *ira, |
| 20022 | 20023 | resolve_top_level_decl(ira->codegen, tld, source_instr->source_node, false); |
| 20023 | 20024 | if (tld->resolution == TldResolutionInvalid) |
| 20024 | 20025 | return ira->codegen->invalid_instruction; |
| 20026 | if (tld->resolution == TldResolutionResolving) |
| 20027 | return ir_error_dependency_loop(ira, source_instr); |
| 20028 | |
| 20025 | 20029 | TldFn *tld_fn = (TldFn *)tld; |
| 20026 | 20030 | ZigFn *fn_entry = tld_fn->fn_entry; |
| 20031 | assert(fn_entry != nullptr); |
| 20032 | |
| 20027 | 20033 | if (type_is_invalid(fn_entry->type_entry)) |
| 20028 | 20034 | return ira->codegen->invalid_instruction; |
| 20029 | 20035 | |
| ... | ... | @@ -20034,8 +20040,13 @@ static IrInstruction *ir_analyze_container_member_access_inner(IrAnalyze *ira, |
| 20034 | 20040 | resolve_top_level_decl(ira->codegen, tld, source_instr->source_node, false); |
| 20035 | 20041 | if (tld->resolution == TldResolutionInvalid) |
| 20036 | 20042 | return ira->codegen->invalid_instruction; |
| 20043 | if (tld->resolution == TldResolutionResolving) |
| 20044 | return ir_error_dependency_loop(ira, source_instr); |
| 20045 | |
| 20037 | 20046 | TldVar *tld_var = (TldVar *)tld; |
| 20038 | 20047 | ZigVar *var = tld_var->var; |
| 20048 | assert(var != nullptr); |
| 20049 | |
| 20039 | 20050 | if (type_is_invalid(var->var_type)) |
| 20040 | 20051 | return ira->codegen->invalid_instruction; |
| 20041 | 20052 | |
| ... | ... | @@ -20369,9 +20380,10 @@ static IrInstruction *ir_error_dependency_loop(IrAnalyze *ira, IrInstruction *so |
| 20369 | 20380 | |
| 20370 | 20381 | static IrInstruction *ir_analyze_decl_ref(IrAnalyze *ira, IrInstruction *source_instruction, Tld *tld) { |
| 20371 | 20382 | resolve_top_level_decl(ira->codegen, tld, source_instruction->source_node, true); |
| 20372 | | if (tld->resolution == TldResolutionInvalid) { |
| 20383 | if (tld->resolution == TldResolutionInvalid) |
| 20373 | 20384 | return ira->codegen->invalid_instruction; |
| 20374 | | } |
| 20385 | if (tld->resolution == TldResolutionResolving) |
| 20386 | return ir_error_dependency_loop(ira, source_instruction); |
| 20375 | 20387 | |
| 20376 | 20388 | switch (tld->id) { |
| 20377 | 20389 | case TldIdContainer: |
| ... | ... | @@ -20381,9 +20393,8 @@ static IrInstruction *ir_analyze_decl_ref(IrAnalyze *ira, IrInstruction *source_ |
| 20381 | 20393 | case TldIdVar: { |
| 20382 | 20394 | TldVar *tld_var = (TldVar *)tld; |
| 20383 | 20395 | ZigVar *var = tld_var->var; |
| 20384 | | if (var == nullptr) { |
| 20385 | | return ir_error_dependency_loop(ira, source_instruction); |
| 20386 | | } |
| 20396 | assert(var != nullptr); |
| 20397 | |
| 20387 | 20398 | if (tld_var->extern_lib_name != nullptr) { |
| 20388 | 20399 | add_link_lib_symbol(ira, tld_var->extern_lib_name, buf_create_from_str(var->name), |
| 20389 | 20400 | source_instruction->source_node); |
| ... | ... | @@ -20394,7 +20405,7 @@ static IrInstruction *ir_analyze_decl_ref(IrAnalyze *ira, IrInstruction *source_ |
| 20394 | 20405 | case TldIdFn: { |
| 20395 | 20406 | TldFn *tld_fn = (TldFn *)tld; |
| 20396 | 20407 | ZigFn *fn_entry = tld_fn->fn_entry; |
| 20397 | | assert(fn_entry->type_entry); |
| 20408 | assert(fn_entry->type_entry != nullptr); |
| 20398 | 20409 | |
| 20399 | 20410 | if (type_is_invalid(fn_entry->type_entry)) |
| 20400 | 20411 | return ira->codegen->invalid_instruction; |
| ... | ... | @@ -22628,11 +22639,14 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInstruction *source_instr |
| 22628 | 22639 | |
| 22629 | 22640 | while ((curr_entry = decl_it.next()) != nullptr) { |
| 22630 | 22641 | // If the declaration is unresolved, force it to be resolved again. |
| 22631 | | if (curr_entry->value->resolution == TldResolutionUnresolved) { |
| 22632 | | resolve_top_level_decl(ira->codegen, curr_entry->value, curr_entry->value->source_node, false); |
| 22633 | | if (curr_entry->value->resolution != TldResolutionOk) { |
| 22634 | | return ErrorSemanticAnalyzeFail; |
| 22635 | | } |
| 22642 | resolve_top_level_decl(ira->codegen, curr_entry->value, curr_entry->value->source_node, false); |
| 22643 | if (curr_entry->value->resolution == TldResolutionInvalid) { |
| 22644 | return ErrorSemanticAnalyzeFail; |
| 22645 | } |
| 22646 | |
| 22647 | if (curr_entry->value->resolution == TldResolutionResolving) { |
| 22648 | ir_error_dependency_loop(ira, source_instr); |
| 22649 | return ErrorSemanticAnalyzeFail; |
| 22636 | 22650 | } |
| 22637 | 22651 | |
| 22638 | 22652 | // Skip comptime blocks and test functions. |
| ... | ... | @@ -22689,6 +22703,8 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInstruction *source_instr |
| 22689 | 22703 | case TldIdVar: |
| 22690 | 22704 | { |
| 22691 | 22705 | ZigVar *var = ((TldVar *)curr_entry->value)->var; |
| 22706 | assert(var != nullptr); |
| 22707 | |
| 22692 | 22708 | if ((err = type_resolve(ira->codegen, var->const_value->type, ResolveStatusSizeKnown))) |
| 22693 | 22709 | return ErrorSemanticAnalyzeFail; |
| 22694 | 22710 | |
| ... | ... | @@ -22719,11 +22735,7 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInstruction *source_instr |
| 22719 | 22735 | |
| 22720 | 22736 | ZigFn *fn_entry = ((TldFn *)curr_entry->value)->fn_entry; |
| 22721 | 22737 | assert(!fn_entry->is_test); |
| 22722 | | |
| 22723 | | if (fn_entry->type_entry == nullptr) { |
| 22724 | | ir_error_dependency_loop(ira, source_instr); |
| 22725 | | return ErrorSemanticAnalyzeFail; |
| 22726 | | } |
| 22738 | assert(fn_entry->type_entry != nullptr); |
| 22727 | 22739 | |
| 22728 | 22740 | AstNodeFnProto *fn_node = &fn_entry->proto_node->data.fn_proto; |
| 22729 | 22741 | |