| ... | @@ -8601,6 +8601,15 @@ static TypeTableEntry *ir_analyze_instruction_br(IrAnalyze *ira, IrInstructionBr | ... | @@ -8601,6 +8601,15 @@ static TypeTableEntry *ir_analyze_instruction_br(IrAnalyze *ira, IrInstructionBr |
| 8601 | return ir_inline_bb(ira, &br_instruction->base, old_dest_block); | 8601 | return ir_inline_bb(ira, &br_instruction->base, old_dest_block); |
| 8602 | | 8602 | |
| 8603 | IrBasicBlock *new_bb = ir_get_new_bb(ira, old_dest_block, &br_instruction->base); | 8603 | IrBasicBlock *new_bb = ir_get_new_bb(ira, old_dest_block, &br_instruction->base); |
| | 8604 | |
| | 8605 | if (new_bb->must_be_comptime_source_instr) { |
| | 8606 | ErrorMsg *msg = ir_add_error(ira, &br_instruction->base, |
| | 8607 | buf_sprintf("control flow attempts to use compile-time variable at runtime")); |
| | 8608 | add_error_note(ira->codegen, msg, new_bb->must_be_comptime_source_instr->source_node, |
| | 8609 | buf_sprintf("compile-time variable assigned here")); |
| | 8610 | return ir_unreach_error(ira); |
| | 8611 | } |
| | 8612 | |
| 8604 | ir_build_br_from(&ira->new_irb, &br_instruction->base, new_bb); | 8613 | ir_build_br_from(&ira->new_irb, &br_instruction->base, new_bb); |
| 8605 | return ir_finish_anal(ira, ira->codegen->builtin_types.entry_unreachable); | 8614 | return ir_finish_anal(ira, ira->codegen->builtin_types.entry_unreachable); |
| 8606 | } | 8615 | } |
| ... | @@ -9392,6 +9401,9 @@ static TypeTableEntry *ir_analyze_instruction_store_ptr(IrAnalyze *ira, IrInstru | ... | @@ -9392,6 +9401,9 @@ static TypeTableEntry *ir_analyze_instruction_store_ptr(IrAnalyze *ira, IrInstru |
| 9392 | ConstExprValue *dest_val = const_ptr_pointee(&ptr->value); | 9401 | ConstExprValue *dest_val = const_ptr_pointee(&ptr->value); |
| 9393 | if (dest_val->special != ConstValSpecialRuntime) { | 9402 | if (dest_val->special != ConstValSpecialRuntime) { |
| 9394 | *dest_val = casted_value->value; | 9403 | *dest_val = casted_value->value; |
| | 9404 | if (!ira->new_irb.current_basic_block->must_be_comptime_source_instr) { |
| | 9405 | ira->new_irb.current_basic_block->must_be_comptime_source_instr = &store_ptr_instruction->base; |
| | 9406 | } |
| 9395 | return ir_analyze_void(ira, &store_ptr_instruction->base); | 9407 | return ir_analyze_void(ira, &store_ptr_instruction->base); |
| 9396 | } | 9408 | } |
| 9397 | } | 9409 | } |