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,...@@ -17030,8 +17030,10 @@ static IrInstGen *ir_analyze_tuple_cat(IrAnalyze *ira, IrInst* source_instr,
17030 continue;17030 continue;
17031 }17031 }
17032 IrInstGen *deref = ir_get_deref(ira, &elem_result_loc->base, elem_result_loc, nullptr);17032 IrInstGen *deref = ir_get_deref(ira, &elem_result_loc->base, elem_result_loc, nullptr);
17033 elem_result_loc->value->special = ConstValSpecialRuntime;17033 if (!type_requires_comptime(ira->codegen, elem_result_loc->value->type->data.pointer.child_type)) {
17034 ir_analyze_store_ptr(ira, &elem_result_loc->base, elem_result_loc, deref, false);17034 elem_result_loc->value->special = ConstValSpecialRuntime;
17035 }
17036 ir_analyze_store_ptr(ira, &elem_result_loc->base, elem_result_loc, deref, true);
17035 }17037 }
17036 }17038 }
17037 IrInstGen *result = ir_get_deref(ira, source_instr, new_struct_ptr, nullptr);17039 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,...@@ -18904,7 +18906,10 @@ static IrInstGen *ir_analyze_store_ptr(IrAnalyze *ira, IrInst* source_instr,
18904 }18906 }
1890518907
18906 if (ptr->value->type->data.pointer.is_const && !allow_write_through_const) {18908 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]"));
18908 return ira->codegen->invalid_inst_gen;18913 return ira->codegen->invalid_inst_gen;
18909 }18914 }
1891018915
...@@ -23042,8 +23047,11 @@ static IrInstGen *ir_analyze_instruction_container_init_list(IrAnalyze *ira,...@@ -23042,8 +23047,11 @@ static IrInstGen *ir_analyze_instruction_container_init_list(IrAnalyze *ira,
23042 }23047 }
23043 }23048 }
2304423049
23050 const_ptrs.deinit();
23051
23045 IrInstGen *result = ir_get_deref(ira, &instruction->base.base, result_loc, nullptr);23052 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))
23047 return result;23055 return result;
2304823056
23049 if (is_comptime) {23057 if (is_comptime) {