authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-06-25 16:04:01-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-06-25 16:04:01-04:00
logda68aec3393648fd89262b2142766d9f734720dc
tree224cd251b363dd4b2a32d19121bc695a87bc800c
parentcb55803a59d4fe99b527dc3ffc5674666511f729
signaturelock-open Commit is signed but in an unrecognized format.

fix infinite loop when error in peer resolution


1 files changed, 21 insertions(+), 8 deletions(-)

src/ir.cpp+21-8
......@@ -203,7 +203,7 @@ static ConstExprValue *const_ptr_pointee_unchecked(CodeGen *g, ConstExprValue *c
203203 assert(get_src_ptr_type(const_val->type) != nullptr);
204204 assert(const_val->special == ConstValSpecialStatic);
205205 ConstExprValue *result;
206
206
207207 switch (type_has_one_possible_value(g, const_val->type->data.pointer.child_type)) {
208208 case OnePossibleValueInvalid:
209209 zig_unreachable();
......@@ -215,7 +215,7 @@ static ConstExprValue *const_ptr_pointee_unchecked(CodeGen *g, ConstExprValue *c
215215 case OnePossibleValueNo:
216216 break;
217217 }
218
218
219219 switch (const_val->data.x_ptr.special) {
220220 case ConstPtrSpecialInvalid:
221221 zig_unreachable();
......@@ -4242,7 +4242,7 @@ static void populate_invalid_variable_in_scope(CodeGen *g, Scope *scope, AstNode
42424242 TldVar *tld_var = allocate<TldVar>(1);
42434243 init_tld(&tld_var->base, TldIdVar, var_name, VisibModPub, node, &scope_decls->base);
42444244 tld_var->base.resolution = TldResolutionInvalid;
4245 tld_var->var = add_variable(g, node, &scope_decls->base, var_name, false,
4245 tld_var->var = add_variable(g, node, &scope_decls->base, var_name, false,
42464246 &g->invalid_instruction->value, &tld_var->base, g->builtin_types.entry_invalid);
42474247 scope_decls->decl_table.put(var_name, &tld_var->base);
42484248}
......@@ -11031,7 +11031,7 @@ static void ir_start_next_bb(IrAnalyze *ira) {
1103111031 ira->old_bb_index += 1;
1103211032 continue;
1103311033 }
11034 // if it's already started, or
11034 // if it's already started, or
1103511035 // if it's a suspended block,
1103611036 // then skip it
1103711037 if (old_bb->suspended ||
......@@ -13259,7 +13259,7 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp *
1325913259 } else {
1326013260 return is_non_null;
1326113261 }
13262 } else if (is_equality_cmp &&
13262 } else if (is_equality_cmp &&
1326313263 ((op1->value.type->id == ZigTypeIdNull && op2->value.type->id == ZigTypeIdPointer &&
1326413264 op2->value.type->data.pointer.ptr_len == PtrLenC) ||
1326513265 (op2->value.type->id == ZigTypeIdNull && op1->value.type->id == ZigTypeIdPointer &&
......@@ -16822,6 +16822,11 @@ static IrInstruction *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionPh
1682216822 peer_parent->done_resuming = true;
1682316823 return ira_resume(ira);
1682416824 }
16825 if (peer_parent != nullptr && !peer_parent->skipped && peer_parent->base.resolved_loc != nullptr &&
16826 type_is_invalid(peer_parent->base.resolved_loc->value.type))
16827 {
16828 return ira->codegen->invalid_instruction;
16829 }
1682516830
1682616831 ZigList<IrBasicBlock*> new_incoming_blocks = {0};
1682716832 ZigList<IrInstruction*> new_incoming_values = {0};
......@@ -20966,7 +20971,7 @@ static IrInstruction *ir_analyze_instruction_c_import(IrAnalyze *ira, IrInstruct
2096620971 ir_add_error_node(ira, node, buf_sprintf("C import failed: unable to make dir: %s", err_str(err)));
2096720972 return ira->codegen->invalid_instruction;
2096820973 }
20969
20974
2097020975 if ((err = os_write_file(&tmp_c_file_path, &cimport_scope->buf))) {
2097120976 ir_add_error_node(ira, node, buf_sprintf("C import failed: unable to write .h file: %s", err_str(err)));
2097220977 return ira->codegen->invalid_instruction;
......@@ -21933,7 +21938,7 @@ static IrInstruction *ir_analyze_instruction_memcpy(IrAnalyze *ira, IrInstructio
2193321938 return ira->codegen->invalid_instruction;
2193421939
2193521940 // TODO test this at comptime with u8 and non-u8 types
21936 // TODO test with dest ptr being a global runtime variable
21941 // TODO test with dest ptr being a global runtime variable
2193721942 if (casted_dest_ptr->value.special == ConstValSpecialStatic &&
2193821943 casted_src_ptr->value.special == ConstValSpecialStatic &&
2193921944 casted_count->value.special == ConstValSpecialStatic &&
......@@ -24789,7 +24794,15 @@ static IrInstruction *ir_analyze_instruction_end_expr(IrAnalyze *ira, IrInstruct
2478924794 return result_loc;
2479024795
2479124796 if (!was_written) {
24792 ir_analyze_store_ptr(ira, &instruction->base, result_loc, value);
24797 IrInstruction *store_ptr = ir_analyze_store_ptr(ira, &instruction->base, result_loc, value);
24798 if (type_is_invalid(store_ptr->value.type)) {
24799 instruction->result_loc->resolved_loc = ira->codegen->invalid_instruction;
24800 if (instruction->result_loc->id == ResultLocIdPeer) {
24801 reinterpret_cast<ResultLocPeer *>(instruction->result_loc)->parent->base.resolved_loc =
24802 ira->codegen->invalid_instruction;
24803 }
24804 return ira->codegen->invalid_instruction;
24805 }
2479324806 }
2479424807
2479524808 if (result_loc->value.data.x_ptr.mut == ConstPtrMutInfer) {