| ... | ... | @@ -20638,12 +20638,12 @@ static IrInstGen *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstSrcElemP |
| 20638 | 20638 | if (type_is_invalid(array_ptr->value->type)) |
| 20639 | 20639 | return ira->codegen->invalid_inst_gen; |
| 20640 | 20640 | |
| 20641 | | ZigValue *orig_array_ptr_val = array_ptr->value; |
| 20642 | | |
| 20643 | 20641 | IrInstGen *elem_index = elem_ptr_instruction->elem_index->child; |
| 20644 | 20642 | if (type_is_invalid(elem_index->value->type)) |
| 20645 | 20643 | return ira->codegen->invalid_inst_gen; |
| 20646 | 20644 | |
| 20645 | ZigValue *orig_array_ptr_val = array_ptr->value; |
| 20646 | |
| 20647 | 20647 | ZigType *ptr_type = orig_array_ptr_val->type; |
| 20648 | 20648 | assert(ptr_type->id == ZigTypeIdPointer); |
| 20649 | 20649 | |
| ... | ... | @@ -20653,23 +20653,25 @@ static IrInstGen *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstSrcElemP |
| 20653 | 20653 | // We will adjust return_type's alignment before returning it. |
| 20654 | 20654 | ZigType *return_type; |
| 20655 | 20655 | |
| 20656 | | if (type_is_invalid(array_type)) { |
| 20656 | if (type_is_invalid(array_type)) |
| 20657 | 20657 | return ira->codegen->invalid_inst_gen; |
| 20658 | | } else if (array_type->id == ZigTypeIdArray || |
| 20659 | | (array_type->id == ZigTypeIdPointer && |
| 20660 | | array_type->data.pointer.ptr_len == PtrLenSingle && |
| 20661 | | array_type->data.pointer.child_type->id == ZigTypeIdArray)) |
| 20658 | |
| 20659 | if (array_type->id == ZigTypeIdPointer && |
| 20660 | array_type->data.pointer.ptr_len == PtrLenSingle && |
| 20661 | array_type->data.pointer.child_type->id == ZigTypeIdArray) |
| 20662 | 20662 | { |
| 20663 | | if (array_type->id == ZigTypeIdPointer) { |
| 20664 | | array_type = array_type->data.pointer.child_type; |
| 20665 | | ptr_type = ptr_type->data.pointer.child_type; |
| 20666 | | if (orig_array_ptr_val->special != ConstValSpecialRuntime) { |
| 20667 | | orig_array_ptr_val = const_ptr_pointee(ira, ira->codegen, orig_array_ptr_val, |
| 20668 | | elem_ptr_instruction->base.base.source_node); |
| 20669 | | if (orig_array_ptr_val == nullptr) |
| 20670 | | return ira->codegen->invalid_inst_gen; |
| 20671 | | } |
| 20672 | | } |
| 20663 | IrInstGen *ptr_value = ir_get_deref(ira, &elem_ptr_instruction->base.base, |
| 20664 | array_ptr, nullptr); |
| 20665 | if (type_is_invalid(ptr_value->value->type)) |
| 20666 | return ira->codegen->invalid_inst_gen; |
| 20667 | |
| 20668 | array_type = array_type->data.pointer.child_type; |
| 20669 | ptr_type = ptr_type->data.pointer.child_type; |
| 20670 | |
| 20671 | orig_array_ptr_val = ptr_value->value; |
| 20672 | } |
| 20673 | |
| 20674 | if (array_type->id == ZigTypeIdArray) { |
| 20673 | 20675 | if (array_type->data.array.len == 0) { |
| 20674 | 20676 | ir_add_error_node(ira, elem_ptr_instruction->base.base.source_node, |
| 20675 | 20677 | buf_sprintf("index 0 outside array of size 0")); |
| ... | ... | @@ -20807,8 +20809,14 @@ static IrInstGen *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstSrcElemP |
| 20807 | 20809 | orig_array_ptr_val->data.x_ptr.special != ConstPtrSpecialHardCodedAddr && |
| 20808 | 20810 | (orig_array_ptr_val->data.x_ptr.mut != ConstPtrMutRuntimeVar || array_type->id == ZigTypeIdArray)) |
| 20809 | 20811 | { |
| 20812 | if ((err = ir_resolve_const_val(ira->codegen, ira->new_irb.exec, |
| 20813 | elem_ptr_instruction->base.base.source_node, orig_array_ptr_val, UndefBad))) |
| 20814 | { |
| 20815 | return ira->codegen->invalid_inst_gen; |
| 20816 | } |
| 20817 | |
| 20810 | 20818 | ZigValue *array_ptr_val = const_ptr_pointee(ira, ira->codegen, orig_array_ptr_val, |
| 20811 | | elem_ptr_instruction->base.base.source_node); |
| 20819 | elem_ptr_instruction->base.base.source_node); |
| 20812 | 20820 | if (array_ptr_val == nullptr) |
| 20813 | 20821 | return ira->codegen->invalid_inst_gen; |
| 20814 | 20822 | |