aboutsummaryrefslogtreecommitdiff
path: root/src/ir.cpp
diff options
context:
space:
mode:
authorVexu <git@vexu.eu>2020-05-04 14:28:58 +0300
committerVexu <git@vexu.eu>2020-05-04 14:28:58 +0300
commitadc444ceeb91c06a6ee84dc4e4874294a41dee45 (patch)
treed69253d7044ad741b64ee61abed86d8a2cb7a890 /src/ir.cpp
parente72f45475d05fb446e48d3e34e6c8e367916bd50 (diff)
downloadzig-adc444ceeb91c06a6ee84dc4e4874294a41dee45.tar.gz
zig-adc444ceeb91c06a6ee84dc4e4874294a41dee45.zip
fix missing compile error on call assigned to const
Diffstat (limited to 'src/ir.cpp')
-rw-r--r--src/ir.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/ir.cpp b/src/ir.cpp
index 4795645544..b636ac6f76 100644
--- a/src/ir.cpp
+++ b/src/ir.cpp
@@ -20000,6 +20000,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,
@@ -20138,6 +20143,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,