@@ -23552,10 +23552,14 @@ static IrInstGen *ir_analyze_instruction_container_init_list(IrAnalyze *ira,
23552
23552
IrInstGen *result_loc = instruction->result_loc->child;
23553
23553
if (type_is_invalid(result_loc->value->type))
23554
23554
return result_loc;
23555
+
23555
23556
ir_assert(result_loc->value->type->id == ZigTypeIdPointer, &instruction->base.base);
23557
+ if (result_loc->value->type->data.pointer.is_const) {
23558
+ ir_add_error(ira, &instruction->base.base, buf_sprintf("cannot assign to constant"));
23559
+ return ira->codegen->invalid_inst_gen;
23560
+ }
23556
23561
23557
23562
ZigType *container_type = result_loc->value->type->data.pointer.child_type;
23558
-
23559
23563
size_t elem_count = instruction->item_count;
23560
23564
23561
23565
if (is_slice(container_type)) {
@@ -23706,6 +23710,11 @@ static IrInstGen *ir_analyze_instruction_container_init_fields(IrAnalyze *ira,
23706
23710
return result_loc;
23707
23711
23708
23712
ir_assert(result_loc->value->type->id == ZigTypeIdPointer, &instruction->base.base);
23713
+ if (result_loc->value->type->data.pointer.is_const) {
23714
+ ir_add_error(ira, &instruction->base.base, buf_sprintf("cannot assign to constant"));
23715
+ return ira->codegen->invalid_inst_gen;
23716
+ }
23717
+
23709
23718
ZigType *container_type = result_loc->value->type->data.pointer.child_type;
23710
23719
23711
23720
return ir_analyze_container_init_fields(ira, &instruction->base.base, container_type,
@@ -27176,11 +27185,8 @@ static IrInstGen *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstSrcSlice *i
27176
27185
return result_loc;
27177
27186
}
27178
27187
27179
- if (result_loc->value->type->id == ZigTypeIdPointer &&
27180
- result_loc->value->type->data.pointer.is_const &&
27181
- instruction->result_loc->id == ResultLocIdInstruction &&
27182
- !instruction->result_loc->allow_write_through_const)
27183
- {
27188
+ ir_assert(result_loc->value->type->id == ZigTypeIdPointer, &instruction->base.base);
27189
+ if (result_loc->value->type->data.pointer.is_const) {
27184
27190
ir_add_error(ira, &instruction->base.base, buf_sprintf("cannot assign to constant"));
27185
27191
return ira->codegen->invalid_inst_gen;
27186
27192
}
@@ -29918,15 +29924,8 @@ static IrInstGen *ir_analyze_instruction_end_expr(IrAnalyze *ira, IrInstSrcEndEx
29918
29924
return result_loc;
29919
29925
29920
29926
if (!was_written || instruction->result_loc->id == ResultLocIdPeer) {
29921
- bool can_write_to_const_ptr = true;
29922
- if (result_loc->value->type->id == ZigTypeIdPointer &&
29923
- result_loc->value->type->data.pointer.is_const &&
29924
- instruction->result_loc->id == ResultLocIdInstruction)
29925
- {
29926
- can_write_to_const_ptr = false;
29927
- }
29928
29927
IrInstGen *store_ptr = ir_analyze_store_ptr(ira, &instruction->base.base, result_loc, value,
29929
- instruction->result_loc->allow_write_through_const && can_write_to_const_ptr );
29928
+ instruction->result_loc->allow_write_through_const);
29930
29929
if (type_is_invalid(store_ptr->value->type)) {
29931
29930
return ira->codegen->invalid_inst_gen;
29932
29931
}
0 commit comments