| ... | ... | @@ -26599,6 +26599,23 @@ static IrInstruction *ir_analyze_ptr_cast(IrAnalyze *ira, IrInstruction *source_ |
| 26599 | 26599 | if ((err = resolve_ptr_align(ira, dest_type, &dest_align_bytes))) |
| 26600 | 26600 | return ira->codegen->invalid_instruction; |
| 26601 | 26601 | |
| 26602 | if ((err = type_resolve(ira->codegen, dest_type, ResolveStatusZeroBitsKnown))) |
| 26603 | return ira->codegen->invalid_instruction; |
| 26604 | |
| 26605 | if ((err = type_resolve(ira->codegen, src_type, ResolveStatusZeroBitsKnown))) |
| 26606 | return ira->codegen->invalid_instruction; |
| 26607 | |
| 26608 | if (type_has_bits(dest_type) && !type_has_bits(src_type)) { |
| 26609 | ErrorMsg *msg = ir_add_error(ira, source_instr, |
| 26610 | buf_sprintf("'%s' and '%s' do not have the same in-memory representation", |
| 26611 | buf_ptr(&src_type->name), buf_ptr(&dest_type->name))); |
| 26612 | add_error_note(ira->codegen, msg, ptr->source_node, |
| 26613 | buf_sprintf("'%s' has no in-memory bits", buf_ptr(&src_type->name))); |
| 26614 | add_error_note(ira->codegen, msg, dest_type_src->source_node, |
| 26615 | buf_sprintf("'%s' has in-memory bits", buf_ptr(&dest_type->name))); |
| 26616 | return ira->codegen->invalid_instruction; |
| 26617 | } |
| 26618 | |
| 26602 | 26619 | if (instr_is_comptime(ptr)) { |
| 26603 | 26620 | bool dest_allows_addr_zero = ptr_allows_addr_zero(dest_type); |
| 26604 | 26621 | UndefAllowed is_undef_allowed = dest_allows_addr_zero ? UndefOk : UndefBad; |
| ... | ... | @@ -26649,23 +26666,6 @@ static IrInstruction *ir_analyze_ptr_cast(IrAnalyze *ira, IrInstruction *source_ |
| 26649 | 26666 | |
| 26650 | 26667 | IrInstruction *casted_ptr = ir_build_ptr_cast_gen(ira, source_instr, dest_type, ptr, safety_check_on); |
| 26651 | 26668 | |
| 26652 | | if ((err = type_resolve(ira->codegen, dest_type, ResolveStatusZeroBitsKnown))) |
| 26653 | | return ira->codegen->invalid_instruction; |
| 26654 | | |
| 26655 | | if ((err = type_resolve(ira->codegen, src_type, ResolveStatusZeroBitsKnown))) |
| 26656 | | return ira->codegen->invalid_instruction; |
| 26657 | | |
| 26658 | | if (type_has_bits(dest_type) && !type_has_bits(src_type)) { |
| 26659 | | ErrorMsg *msg = ir_add_error(ira, source_instr, |
| 26660 | | buf_sprintf("'%s' and '%s' do not have the same in-memory representation", |
| 26661 | | buf_ptr(&src_type->name), buf_ptr(&dest_type->name))); |
| 26662 | | add_error_note(ira->codegen, msg, ptr->source_node, |
| 26663 | | buf_sprintf("'%s' has no in-memory bits", buf_ptr(&src_type->name))); |
| 26664 | | add_error_note(ira->codegen, msg, dest_type_src->source_node, |
| 26665 | | buf_sprintf("'%s' has in-memory bits", buf_ptr(&dest_type->name))); |
| 26666 | | return ira->codegen->invalid_instruction; |
| 26667 | | } |
| 26668 | | |
| 26669 | 26669 | // Keep the bigger alignment, it can only help- |
| 26670 | 26670 | // unless the target is zero bits. |
| 26671 | 26671 | IrInstruction *result; |