authorgravatar for alex_naskos@hotmail.comAlexandros Naskos <alex_naskos@hotmail.com> 2020-02-28 02:19:17+02:00
committergravatar for alex_naskos@hotmail.comAlexandros Naskos <alex_naskos@hotmail.com> 2020-02-28 02:19:17+02:00
log95a1d2feb496d64094d81c9477465cafc73ce49b
tree8cd3c46ba90acd0885c1144ce64de223e18b3198
parent2696c8b42d7fcec1b8cf3f332742df4638c519b1

Fixed tuple concatenation with runtime and comptime values.


1 files changed, 12 insertions(+), 4 deletions(-)

src/ir.cpp+12-4
......@@ -17030,8 +17030,10 @@ static IrInstGen *ir_analyze_tuple_cat(IrAnalyze *ira, IrInst* source_instr,
1703017030 continue;
1703117031 }
1703217032 IrInstGen *deref = ir_get_deref(ira, &elem_result_loc->base, elem_result_loc, nullptr);
17033 elem_result_loc->value->special = ConstValSpecialRuntime;
17034 ir_analyze_store_ptr(ira, &elem_result_loc->base, elem_result_loc, deref, false);
17033 if (!type_requires_comptime(ira->codegen, elem_result_loc->value->type->data.pointer.child_type)) {
17034 elem_result_loc->value->special = ConstValSpecialRuntime;
17035 }
17036 ir_analyze_store_ptr(ira, &elem_result_loc->base, elem_result_loc, deref, true);
1703517037 }
1703617038 }
1703717039 IrInstGen *result = ir_get_deref(ira, source_instr, new_struct_ptr, nullptr);
......@@ -18904,7 +18906,10 @@ static IrInstGen *ir_analyze_store_ptr(IrAnalyze *ira, IrInst* source_instr,
1890418906 }
1890518907
1890618908 if (ptr->value->type->data.pointer.is_const && !allow_write_through_const) {
18907 ir_add_error(ira, source_instr, buf_sprintf("cannot assign to constant"));
18909 // @TODO
18910 fprintf(stderr, "store ptr\n");
18911 ptr->src();
18912 ir_add_error(ira, source_instr, buf_sprintf("cannot assign to constant [FOO]"));
1890818913 return ira->codegen->invalid_inst_gen;
1890918914 }
1891018915
......@@ -23042,8 +23047,11 @@ static IrInstGen *ir_analyze_instruction_container_init_list(IrAnalyze *ira,
2304223047 }
2304323048 }
2304423049
23050 const_ptrs.deinit();
23051
2304523052 IrInstGen *result = ir_get_deref(ira, &instruction->base.base, result_loc, nullptr);
23046 if (instr_is_comptime(result))
23053 // If the result is a tuple, we are allowed to use ConstValSpecialRuntime fields.
23054 if (instr_is_comptime(result) || is_tuple(container_type))
2304723055 return result;
2304823056
2304923057 if (is_comptime) {