diff options
| author | Vexu <git@vexu.eu> | 2020-05-04 21:45:15 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-05-04 21:45:15 +0300 |
| commit | f127dee47424f4c87a4ed5026a2d5be5cce7a135 (patch) | |
| tree | 46ccfd32c7990bb0772fb05f9aa804ec1e6932a8 /src/ir.cpp | |
| parent | 75b699b2c624d62a4b6717f00bd0856b86c3f990 (diff) | |
| parent | 85fd484f0778b5f158dc76bf51b820314b86292d (diff) | |
| download | zig-f127dee47424f4c87a4ed5026a2d5be5cce7a135.tar.gz zig-f127dee47424f4c87a4ed5026a2d5be5cce7a135.zip | |
Merge pull request #5267 from Vexu/const-call
Fix missing compile error on call assigned to const
Diffstat (limited to 'src/ir.cpp')
| -rw-r--r-- | src/ir.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/ir.cpp b/src/ir.cpp index f37f91088a..a8cc95a040 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -19999,6 +19999,11 @@ 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; } + if (result_loc->value->type->data.pointer.is_const) { + ir_add_error(ira, source_instr, buf_sprintf("cannot assign to constant")); + return ira->codegen->invalid_inst_gen; + } + 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, @@ -20137,6 +20142,11 @@ 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; } + if (result_loc->value->type->data.pointer.is_const) { + ir_add_error(ira, source_instr, buf_sprintf("cannot assign to constant")); + return ira->codegen->invalid_inst_gen; + } + IrInstGen *dummy_value = ir_const(ira, source_instr, return_type); dummy_value->value->special = ConstValSpecialRuntime; IrInstGen *dummy_result = ir_implicit_cast2(ira, source_instr, |
