fix not checking type of return pointer
Thanks to Vexu for the test cases. Closes #3422 Closes #3646 Closes #3224 Closes #3327 Closes #3269
This commit is contained in:
12
src/ir.cpp
12
src/ir.cpp
@@ -19591,6 +19591,12 @@ static IrInstGen *ir_analyze_fn_call(IrAnalyze *ira, IrInst* source_instr,
|
||||
if (type_is_invalid(result_loc->value->type) || result_loc->value->type->id == ZigTypeIdUnreachable) {
|
||||
return result_loc;
|
||||
}
|
||||
IrInstGen *dummy_value = ir_const(ira, source_instr, impl_fn_type_id->return_type);
|
||||
dummy_value->value->special = ConstValSpecialRuntime;
|
||||
IrInstGen *dummy_result = ir_implicit_cast2(ira, source_instr,
|
||||
dummy_value, result_loc->value->type->data.pointer.child_type);
|
||||
if (type_is_invalid(dummy_result->value->type))
|
||||
return ira->codegen->invalid_inst_gen;
|
||||
ZigType *res_child_type = result_loc->value->type->data.pointer.child_type;
|
||||
if (res_child_type == ira->codegen->builtin_types.entry_var) {
|
||||
res_child_type = impl_fn_type_id->return_type;
|
||||
@@ -19723,6 +19729,12 @@ static IrInstGen *ir_analyze_fn_call(IrAnalyze *ira, IrInst* source_instr,
|
||||
if (type_is_invalid(result_loc->value->type) || result_loc->value->type->id == ZigTypeIdUnreachable) {
|
||||
return result_loc;
|
||||
}
|
||||
IrInstGen *dummy_value = ir_const(ira, source_instr, return_type);
|
||||
dummy_value->value->special = ConstValSpecialRuntime;
|
||||
IrInstGen *dummy_result = ir_implicit_cast2(ira, source_instr,
|
||||
dummy_value, result_loc->value->type->data.pointer.child_type);
|
||||
if (type_is_invalid(dummy_result->value->type))
|
||||
return ira->codegen->invalid_inst_gen;
|
||||
ZigType *res_child_type = result_loc->value->type->data.pointer.child_type;
|
||||
if (res_child_type == ira->codegen->builtin_types.entry_var) {
|
||||
res_child_type = return_type;
|
||||
|
||||
Reference in New Issue
Block a user