| ... | @@ -9485,10 +9485,6 @@ static ConstCastOnly types_match_const_cast_only(IrAnalyze *ira, ZigType *wanted | ... | @@ -9485,10 +9485,6 @@ static ConstCastOnly types_match_const_cast_only(IrAnalyze *ira, ZigType *wanted |
| 9485 | result.id = ConstCastResultIdFnAlign; | 9485 | result.id = ConstCastResultIdFnAlign; |
| 9486 | return result; | 9486 | return result; |
| 9487 | } | 9487 | } |
| 9488 | if (wanted_type->data.fn.fn_type_id.cc != actual_type->data.fn.fn_type_id.cc) { | | |
| 9489 | result.id = ConstCastResultIdFnCC; | | |
| 9490 | return result; | | |
| 9491 | } | | |
| 9492 | if (wanted_type->data.fn.fn_type_id.is_var_args != actual_type->data.fn.fn_type_id.is_var_args) { | 9488 | if (wanted_type->data.fn.fn_type_id.is_var_args != actual_type->data.fn.fn_type_id.is_var_args) { |
| 9493 | result.id = ConstCastResultIdFnVarArgs; | 9489 | result.id = ConstCastResultIdFnVarArgs; |
| 9494 | return result; | 9490 | return result; |
| ... | @@ -9546,6 +9542,11 @@ static ConstCastOnly types_match_const_cast_only(IrAnalyze *ira, ZigType *wanted | ... | @@ -9546,6 +9542,11 @@ static ConstCastOnly types_match_const_cast_only(IrAnalyze *ira, ZigType *wanted |
| 9546 | return result; | 9542 | return result; |
| 9547 | } | 9543 | } |
| 9548 | } | 9544 | } |
| | 9545 | if (wanted_type->data.fn.fn_type_id.cc != actual_type->data.fn.fn_type_id.cc) { |
| | 9546 | // ConstCastResultIdFnCC is guaranteed to be the last one reported, meaning everything else is ok. |
| | 9547 | result.id = ConstCastResultIdFnCC; |
| | 9548 | return result; |
| | 9549 | } |
| 9549 | return result; | 9550 | return result; |
| 9550 | } | 9551 | } |
| 9551 | | 9552 | |
| ... | @@ -11780,8 +11781,11 @@ static void report_recursive_error(IrAnalyze *ira, AstNode *source_node, ConstCa | ... | @@ -11780,8 +11781,11 @@ static void report_recursive_error(IrAnalyze *ira, AstNode *source_node, ConstCa |
| 11780 | add_error_note(ira->codegen, parent_msg, source_node, | 11781 | add_error_note(ira->codegen, parent_msg, source_node, |
| 11781 | buf_sprintf("only one of the functions is generic")); | 11782 | buf_sprintf("only one of the functions is generic")); |
| 11782 | break; | 11783 | break; |
| | 11784 | case ConstCastResultIdFnCC: |
| | 11785 | add_error_note(ira->codegen, parent_msg, source_node, |
| | 11786 | buf_sprintf("calling convention mismatch")); |
| | 11787 | break; |
| 11783 | case ConstCastResultIdFnAlign: // TODO | 11788 | case ConstCastResultIdFnAlign: // TODO |
| 11784 | case ConstCastResultIdFnCC: // TODO | | |
| 11785 | case ConstCastResultIdFnVarArgs: // TODO | 11789 | case ConstCastResultIdFnVarArgs: // TODO |
| 11786 | case ConstCastResultIdFnReturnType: // TODO | 11790 | case ConstCastResultIdFnReturnType: // TODO |
| 11787 | case ConstCastResultIdFnArgCount: // TODO | 11791 | case ConstCastResultIdFnArgCount: // TODO |
| ... | @@ -11891,6 +11895,21 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst | ... | @@ -11891,6 +11895,21 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 11891 | return ir_resolve_cast(ira, source_instr, value, wanted_type, CastOpNoop); | 11895 | return ir_resolve_cast(ira, source_instr, value, wanted_type, CastOpNoop); |
| 11892 | } | 11896 | } |
| 11893 | | 11897 | |
| | 11898 | if (const_cast_result.id == ConstCastResultIdFnCC) { |
| | 11899 | ir_assert(value->value.type->id == ZigTypeIdFn, source_instr); |
| | 11900 | // ConstCastResultIdFnCC is guaranteed to be the last one reported, meaning everything else is ok. |
| | 11901 | if (wanted_type->data.fn.fn_type_id.cc == CallingConventionAsync && |
| | 11902 | actual_type->data.fn.fn_type_id.cc == CallingConventionUnspecified) |
| | 11903 | { |
| | 11904 | ir_assert(value->value.data.x_ptr.special == ConstPtrSpecialFunction, source_instr); |
| | 11905 | ZigFn *fn = value->value.data.x_ptr.data.fn.fn_entry; |
| | 11906 | if (fn->inferred_async_node == nullptr) { |
| | 11907 | fn->inferred_async_node = source_instr->source_node; |
| | 11908 | } |
| | 11909 | return ir_resolve_cast(ira, source_instr, value, wanted_type, CastOpNoop); |
| | 11910 | } |
| | 11911 | } |
| | 11912 | |
| 11894 | // cast from T to ?T | 11913 | // cast from T to ?T |
| 11895 | // note that the *T to ?*T case is handled via the "ConstCastOnly" mechanism | 11914 | // note that the *T to ?*T case is handled via the "ConstCastOnly" mechanism |
| 11896 | if (wanted_type->id == ZigTypeIdOptional) { | 11915 | if (wanted_type->id == ZigTypeIdOptional) { |