| ... | ... | @@ -10483,31 +10483,6 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 10483 | 10483 | } |
| 10484 | 10484 | } |
| 10485 | 10485 | |
| 10486 | | // cast from [N]T to *const []const T |
| 10487 | | if (wanted_type->id == ZigTypeIdPointer && |
| 10488 | | wanted_type->data.pointer.is_const && |
| 10489 | | is_slice(wanted_type->data.pointer.child_type) && |
| 10490 | | actual_type->id == ZigTypeIdArray) |
| 10491 | | { |
| 10492 | | ZigType *ptr_type = |
| 10493 | | wanted_type->data.pointer.child_type->data.structure.fields[slice_ptr_index].type_entry; |
| 10494 | | assert(ptr_type->id == ZigTypeIdPointer); |
| 10495 | | if ((ptr_type->data.pointer.is_const || actual_type->data.array.len == 0) && |
| 10496 | | types_match_const_cast_only(ira, ptr_type->data.pointer.child_type, actual_type->data.array.child_type, |
| 10497 | | source_node, false).id == ConstCastResultIdOk) |
| 10498 | | { |
| 10499 | | IrInstruction *cast1 = ir_analyze_cast(ira, source_instr, wanted_type->data.pointer.child_type, value); |
| 10500 | | if (type_is_invalid(cast1->value.type)) |
| 10501 | | return ira->codegen->invalid_instruction; |
| 10502 | | |
| 10503 | | IrInstruction *cast2 = ir_analyze_cast(ira, source_instr, wanted_type, cast1); |
| 10504 | | if (type_is_invalid(cast2->value.type)) |
| 10505 | | return ira->codegen->invalid_instruction; |
| 10506 | | |
| 10507 | | return cast2; |
| 10508 | | } |
| 10509 | | } |
| 10510 | | |
| 10511 | 10486 | // cast from [N]T to ?[]const T |
| 10512 | 10487 | if (wanted_type->id == ZigTypeIdOptional && |
| 10513 | 10488 | is_slice(wanted_type->data.maybe.child_type) && |
| ... | ... | @@ -10705,7 +10680,6 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 10705 | 10680 | } |
| 10706 | 10681 | |
| 10707 | 10682 | // cast from number literal to another type |
| 10708 | | // cast from number literal to *const integer |
| 10709 | 10683 | if (actual_type->id == ZigTypeIdComptimeFloat || |
| 10710 | 10684 | actual_type->id == ZigTypeIdComptimeInt) |
| 10711 | 10685 | { |
| ... | ... | @@ -10720,18 +10694,6 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 10720 | 10694 | if (type_is_invalid(cast2->value.type)) |
| 10721 | 10695 | return ira->codegen->invalid_instruction; |
| 10722 | 10696 | |
| 10723 | | return cast2; |
| 10724 | | } else if (wanted_type->id == ZigTypeIdPointer && |
| 10725 | | wanted_type->data.pointer.is_const) |
| 10726 | | { |
| 10727 | | IrInstruction *cast1 = ir_analyze_cast(ira, source_instr, wanted_type->data.pointer.child_type, value); |
| 10728 | | if (type_is_invalid(cast1->value.type)) |
| 10729 | | return ira->codegen->invalid_instruction; |
| 10730 | | |
| 10731 | | IrInstruction *cast2 = ir_analyze_cast(ira, source_instr, wanted_type, cast1); |
| 10732 | | if (type_is_invalid(cast2->value.type)) |
| 10733 | | return ira->codegen->invalid_instruction; |
| 10734 | | |
| 10735 | 10697 | return cast2; |
| 10736 | 10698 | } else if (ir_num_lit_fits_in_other_type(ira, value, wanted_type, true)) { |
| 10737 | 10699 | CastOp op; |
| ... | ... | @@ -10786,29 +10748,6 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 10786 | 10748 | } |
| 10787 | 10749 | } |
| 10788 | 10750 | |
| 10789 | | // enum to *const union which has the enum as the tag type |
| 10790 | | if (actual_type->id == ZigTypeIdEnum && wanted_type->id == ZigTypeIdPointer) { |
| 10791 | | ZigType *union_type = wanted_type->data.pointer.child_type; |
| 10792 | | if (union_type->data.unionation.decl_node->data.container_decl.auto_enum || |
| 10793 | | union_type->data.unionation.decl_node->data.container_decl.init_arg_expr != nullptr) |
| 10794 | | { |
| 10795 | | if ((err = type_resolve(ira->codegen, union_type, ResolveStatusZeroBitsKnown))) |
| 10796 | | return ira->codegen->invalid_instruction; |
| 10797 | | |
| 10798 | | if (union_type->data.unionation.tag_type == actual_type) { |
| 10799 | | IrInstruction *cast1 = ir_analyze_cast(ira, source_instr, union_type, value); |
| 10800 | | if (type_is_invalid(cast1->value.type)) |
| 10801 | | return ira->codegen->invalid_instruction; |
| 10802 | | |
| 10803 | | IrInstruction *cast2 = ir_analyze_cast(ira, source_instr, wanted_type, cast1); |
| 10804 | | if (type_is_invalid(cast2->value.type)) |
| 10805 | | return ira->codegen->invalid_instruction; |
| 10806 | | |
| 10807 | | return cast2; |
| 10808 | | } |
| 10809 | | } |
| 10810 | | } |
| 10811 | | |
| 10812 | 10751 | // cast from *T to *[1]T |
| 10813 | 10752 | if (wanted_type->id == ZigTypeIdPointer && wanted_type->data.pointer.ptr_len == PtrLenSingle && |
| 10814 | 10753 | actual_type->id == ZigTypeIdPointer && actual_type->data.pointer.ptr_len == PtrLenSingle) |