| ... | ... | @@ -9913,8 +9913,8 @@ static TypeTableEntry *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruc |
| 9913 | 9913 | (array_type->id != TypeTableEntryIdPointer || |
| 9914 | 9914 | array_ptr_val->data.x_ptr.special != ConstPtrSpecialHardCodedAddr)) |
| 9915 | 9915 | { |
| 9916 | | ConstExprValue *out_val = ir_build_const_from(ira, &elem_ptr_instruction->base); |
| 9917 | 9916 | if (array_type->id == TypeTableEntryIdPointer) { |
| 9917 | ConstExprValue *out_val = ir_build_const_from(ira, &elem_ptr_instruction->base); |
| 9918 | 9918 | out_val->data.x_ptr.mut = array_ptr_val->data.x_ptr.mut; |
| 9919 | 9919 | size_t new_index; |
| 9920 | 9920 | size_t mem_size; |
| ... | ... | @@ -9959,9 +9959,16 @@ static TypeTableEntry *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruc |
| 9959 | 9959 | buf_sprintf("index %" ZIG_PRI_u64 " outside pointer of size %" ZIG_PRI_usize "", index, old_size)); |
| 9960 | 9960 | return ira->codegen->builtin_types.entry_invalid; |
| 9961 | 9961 | } |
| 9962 | return return_type; |
| 9962 | 9963 | } else if (is_slice(array_type)) { |
| 9963 | 9964 | ConstExprValue *ptr_field = &array_ptr_val->data.x_struct.fields[slice_ptr_index]; |
| 9965 | if (ptr_field->data.x_ptr.special == ConstPtrSpecialHardCodedAddr) { |
| 9966 | ir_build_elem_ptr_from(&ira->new_irb, &elem_ptr_instruction->base, array_ptr, |
| 9967 | casted_elem_index, false); |
| 9968 | return return_type; |
| 9969 | } |
| 9964 | 9970 | ConstExprValue *len_field = &array_ptr_val->data.x_struct.fields[slice_len_index]; |
| 9971 | ConstExprValue *out_val = ir_build_const_from(ira, &elem_ptr_instruction->base); |
| 9965 | 9972 | uint64_t slice_len = len_field->data.x_bignum.data.x_uint; |
| 9966 | 9973 | if (index >= slice_len) { |
| 9967 | 9974 | ir_add_error_node(ira, elem_ptr_instruction->base.source_node, |
| ... | ... | @@ -9996,15 +10003,17 @@ static TypeTableEntry *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruc |
| 9996 | 10003 | case ConstPtrSpecialHardCodedAddr: |
| 9997 | 10004 | zig_unreachable(); |
| 9998 | 10005 | } |
| 10006 | return return_type; |
| 9999 | 10007 | } else if (array_type->id == TypeTableEntryIdArray) { |
| 10008 | ConstExprValue *out_val = ir_build_const_from(ira, &elem_ptr_instruction->base); |
| 10000 | 10009 | out_val->data.x_ptr.special = ConstPtrSpecialBaseArray; |
| 10001 | 10010 | out_val->data.x_ptr.mut = array_ptr->value.data.x_ptr.mut; |
| 10002 | 10011 | out_val->data.x_ptr.data.base_array.array_val = array_ptr_val; |
| 10003 | 10012 | out_val->data.x_ptr.data.base_array.elem_index = index; |
| 10013 | return return_type; |
| 10004 | 10014 | } else { |
| 10005 | 10015 | zig_unreachable(); |
| 10006 | 10016 | } |
| 10007 | | return return_type; |
| 10008 | 10017 | } |
| 10009 | 10018 | |
| 10010 | 10019 | } |