diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2020-02-09 22:34:34 -0500 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2020-02-09 22:34:34 -0500 |
| commit | 5ea79bfc4a0a1269930d98faee36a8f6cb0b0401 (patch) | |
| tree | e69f01abb631fb64fa95556a70d300f41d5b3521 /src/ir.cpp | |
| parent | 04ee3b01a159a25894f93d8448fb766ae545ab53 (diff) | |
| download | zig-5ea79bfc4a0a1269930d98faee36a8f6cb0b0401.tar.gz zig-5ea79bfc4a0a1269930d98faee36a8f6cb0b0401.zip | |
fix not checking type of return pointer
Thanks to Vexu for the test cases.
Closes #3422
Closes #3646
Closes #3224
Closes #3327
Closes #3269
Diffstat (limited to 'src/ir.cpp')
| -rw-r--r-- | src/ir.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/ir.cpp b/src/ir.cpp index 82fce395b0..4716b91b5d 100644 --- a/src/ir.cpp +++ b/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; |
