@@ -13377,30 +13377,25 @@ static IrInstruction *ir_get_var_ptr(IrAnalyze *ira, IrInstruction *instruction,
13377
13377
}
13378
13378
13379
13379
static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source_instr,
13380
- IrInstruction *ptr , IrInstruction *value)
13380
+ IrInstruction *uncasted_ptr , IrInstruction *value)
13381
13381
{
13382
- if (ptr ->value.type->id != ZigTypeIdPointer) {
13383
- ir_add_error(ira, ptr ,
13384
- buf_sprintf("attempt to dereference non pointer type '%s'", buf_ptr(&ptr ->value.type->name)));
13382
+ if (uncasted_ptr ->value.type->id != ZigTypeIdPointer) {
13383
+ ir_add_error(ira, uncasted_ptr ,
13384
+ buf_sprintf("attempt to dereference non pointer type '%s'", buf_ptr(&uncasted_ptr ->value.type->name)));
13385
13385
return ira->codegen->invalid_instruction;
13386
13386
}
13387
13387
13388
- Error err;
13389
- if ((err = resolve_possible_alloca_inference(ira, ptr, value->value.type)))
13390
- return ira->codegen->invalid_instruction;
13391
-
13392
- if (ptr->value.data.x_ptr.special == ConstPtrSpecialDiscard) {
13388
+ if (uncasted_ptr->value.data.x_ptr.special == ConstPtrSpecialDiscard) {
13393
13389
return ir_const_void(ira, source_instr);
13394
13390
}
13395
13391
13396
- if (ptr ->value.type->data.pointer.is_const && !source_instr->is_gen) {
13392
+ if (uncasted_ptr ->value.type->data.pointer.is_const && !source_instr->is_gen) {
13397
13393
ir_add_error(ira, source_instr, buf_sprintf("cannot assign to constant"));
13398
13394
return ira->codegen->invalid_instruction;
13399
13395
}
13400
13396
13401
- ZigType *child_type = ptr->value.type->data.pointer.child_type;
13402
- IrInstruction *casted_value = ir_implicit_cast(ira, value, child_type);
13403
- if (casted_value == ira->codegen->invalid_instruction)
13397
+ IrInstruction *ptr = ir_implicit_cast_result(ira, uncasted_ptr, value->value.type);
13398
+ if (type_is_invalid(ptr->value.type))
13404
13399
return ira->codegen->invalid_instruction;
13405
13400
13406
13401
if (instr_is_comptime(ptr) && ptr->value.data.x_ptr.special != ConstPtrSpecialHardCodedAddr) {
@@ -13409,12 +13404,12 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source
13409
13404
return ira->codegen->invalid_instruction;
13410
13405
}
13411
13406
if (ptr->value.data.x_ptr.mut == ConstPtrMutComptimeVar) {
13412
- if (instr_is_comptime(casted_value )) {
13407
+ if (instr_is_comptime(value )) {
13413
13408
ConstExprValue *dest_val = ir_const_ptr_pointee(ira, &ptr->value, source_instr->source_node);
13414
13409
if (dest_val == nullptr)
13415
13410
return ira->codegen->invalid_instruction;
13416
13411
if (dest_val->special != ConstValSpecialRuntime) {
13417
- *dest_val = casted_value ->value;
13412
+ *dest_val = value ->value;
13418
13413
if (!ira->new_irb.current_basic_block->must_be_comptime_source_instr) {
13419
13414
ira->new_irb.current_basic_block->must_be_comptime_source_instr = source_instr;
13420
13415
}
@@ -13431,7 +13426,7 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source
13431
13426
}
13432
13427
13433
13428
IrInstruction *result = ir_build_store_ptr(&ira->new_irb, source_instr->scope, source_instr->source_node,
13434
- ptr, casted_value );
13429
+ ptr, value );
13435
13430
result->value.type = ira->codegen->builtin_types.entry_void;
13436
13431
return result;
13437
13432
}
0 commit comments