authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-11-24 18:10:31-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-11-24 18:10:31-05:00
log217a5090ffed74f071a5c33798e3de029a2ee3fa
tree9263b3b9daf0fbe9c28e3758a7d0f8b33c1dc5ff
parentc96d565166a4e63487b43d6d50797b1037c9603c
signaturelock-open Commit is signed but in an unrecognized format.

fix compile error regressions


2 files changed, 119 insertions(+), 114 deletions(-)

src/ir.cpp+115-110
......@@ -189,7 +189,8 @@ struct ConstCastPtrSentinel {
189189static IrInstruction *ir_gen_node(IrBuilder *irb, AstNode *node, Scope *scope);
190190static IrInstruction *ir_gen_node_extra(IrBuilder *irb, AstNode *node, Scope *scope, LVal lval,
191191 ResultLoc *result_loc);
192static IrInstruction *ir_implicit_cast(IrAnalyze *ira, IrInstruction *source_instr,
192static IrInstruction *ir_implicit_cast(IrAnalyze *ira, IrInstruction *value, ZigType *expected_type);
193static IrInstruction *ir_implicit_cast2(IrAnalyze *ira, IrInstruction *value_source_instr,
193194 IrInstruction *value, ZigType *expected_type);
194195static IrInstruction *ir_get_deref(IrAnalyze *ira, IrInstruction *source_instruction, IrInstruction *ptr,
195196 ResultLoc *result_loc);
......@@ -11720,7 +11721,7 @@ static IrInstruction *ir_analyze_optional_wrap(IrAnalyze *ira, IrInstruction *so
1172011721
1172111722 if (instr_is_comptime(value)) {
1172211723 ZigType *payload_type = wanted_type->data.maybe.child_type;
11723 IrInstruction *casted_payload = ir_implicit_cast(ira, source_instr, value, payload_type);
11724 IrInstruction *casted_payload = ir_implicit_cast(ira, value, payload_type);
1172411725 if (type_is_invalid(casted_payload->value.type))
1172511726 return ira->codegen->invalid_instruction;
1172611727
......@@ -11763,7 +11764,7 @@ static IrInstruction *ir_analyze_err_wrap_payload(IrAnalyze *ira, IrInstruction
1176311764 ZigType *payload_type = wanted_type->data.error_union.payload_type;
1176411765 ZigType *err_set_type = wanted_type->data.error_union.err_set_type;
1176511766 if (instr_is_comptime(value)) {
11766 IrInstruction *casted_payload = ir_implicit_cast(ira, source_instr, value, payload_type);
11767 IrInstruction *casted_payload = ir_implicit_cast(ira, value, payload_type);
1176711768 if (type_is_invalid(casted_payload->value.type))
1176811769 return ira->codegen->invalid_instruction;
1176911770
......@@ -11883,7 +11884,7 @@ static IrInstruction *ir_analyze_err_wrap_code(IrAnalyze *ira, IrInstruction *so
1188311884{
1188411885 assert(wanted_type->id == ZigTypeIdErrorUnion);
1188511886
11886 IrInstruction *casted_value = ir_implicit_cast(ira, source_instr, value, wanted_type->data.error_union.err_set_type);
11887 IrInstruction *casted_value = ir_implicit_cast(ira, value, wanted_type->data.error_union.err_set_type);
1188711888
1188811889 if (instr_is_comptime(casted_value)) {
1188911890 ConstExprValue *val = ir_resolve_const(ira, casted_value, UndefBad);
......@@ -12068,7 +12069,7 @@ static IrInstruction *ir_analyze_enum_to_int(IrAnalyze *ira, IrInstruction *sour
1206812069 enum_type = ir_resolve_union_tag_type(ira, target, target->value.type);
1206912070 if (type_is_invalid(enum_type))
1207012071 return ira->codegen->invalid_instruction;
12071 enum_target = ir_implicit_cast(ira, source_instr, target, enum_type);
12072 enum_target = ir_implicit_cast(ira, target, enum_type);
1207212073 if (type_is_invalid(enum_target->value.type))
1207312074 return ira->codegen->invalid_instruction;
1207412075 } else if (target->value.type->id == ZigTypeIdEnum) {
......@@ -12164,7 +12165,7 @@ static IrInstruction *ir_analyze_enum_to_union(IrAnalyze *ira, IrInstruction *so
1216412165 if ((err = type_resolve(ira->codegen, wanted_type, ResolveStatusZeroBitsKnown)))
1216512166 return ira->codegen->invalid_instruction;
1216612167
12167 IrInstruction *target = ir_implicit_cast(ira, source_instr, uncasted_target, wanted_type->data.unionation.tag_type);
12168 IrInstruction *target = ir_implicit_cast(ira, uncasted_target, wanted_type->data.unionation.tag_type);
1216812169 if (type_is_invalid(target->value.type))
1216912170 return ira->codegen->invalid_instruction;
1217012171
......@@ -13385,8 +13386,8 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst
1338513386 actual_type->data.pointer.child_type, source_node,
1338613387 !wanted_type->data.pointer.is_const).id == ConstCastResultIdOk &&
1338713388 // `types_match_const_cast_only` only gets info for child_types
13388 (!wanted_type->data.pointer.is_const || actual_type->data.pointer.is_const) &&
13389 (!wanted_type->data.pointer.is_volatile || actual_type->data.pointer.is_volatile))
13389 (!actual_type->data.pointer.is_const || wanted_type->data.pointer.is_const) &&
13390 (!actual_type->data.pointer.is_volatile || wanted_type->data.pointer.is_volatile))
1339013391 {
1339113392 if ((err = ir_cast_ptr_align(ira, source_instr, wanted_type, actual_type, value->source_node)))
1339213393 return ira->codegen->invalid_instruction;
......@@ -13413,7 +13414,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst
1341313414 {
1341413415 TypeStructField *ptr_field = actual_type->data.structure.fields[slice_ptr_index];
1341513416 IrInstruction *slice_ptr = ir_analyze_struct_value_field_value(ira, source_instr, value, ptr_field);
13416 return ir_implicit_cast(ira, source_instr, slice_ptr, wanted_type);
13417 return ir_implicit_cast2(ira, source_instr, slice_ptr, wanted_type);
1341713418 }
1341813419 }
1341913420
......@@ -13516,7 +13517,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst
1351613517 return ira->codegen->invalid_instruction;
1351713518}
1351813519
13519static IrInstruction *ir_implicit_cast(IrAnalyze *ira, IrInstruction *source_instr,
13520static IrInstruction *ir_implicit_cast2(IrAnalyze *ira, IrInstruction *value_source_instr,
1352013521 IrInstruction *value, ZigType *expected_type)
1352113522{
1352213523 assert(value);
......@@ -13531,7 +13532,11 @@ static IrInstruction *ir_implicit_cast(IrAnalyze *ira, IrInstruction *source_ins
1353113532 if (value->value.type->id == ZigTypeIdUnreachable)
1353213533 return value;
1353313534
13534 return ir_analyze_cast(ira, source_instr, expected_type, value);
13535 return ir_analyze_cast(ira, value_source_instr, expected_type, value);
13536}
13537
13538static IrInstruction *ir_implicit_cast(IrAnalyze *ira, IrInstruction *value, ZigType *expected_type) {
13539 return ir_implicit_cast2(ira, value, value, expected_type);
1353513540}
1353613541
1353713542static IrInstruction *ir_get_deref(IrAnalyze *ira, IrInstruction *source_instruction, IrInstruction *ptr,
......@@ -13669,7 +13674,7 @@ static bool ir_resolve_align(IrAnalyze *ira, IrInstruction *value, ZigType *elem
1366913674 }
1367013675 }
1367113676
13672 IrInstruction *casted_value = ir_implicit_cast(ira, value, value, get_align_amt_type(ira->codegen));
13677 IrInstruction *casted_value = ir_implicit_cast(ira, value, get_align_amt_type(ira->codegen));
1367313678 if (type_is_invalid(casted_value->value.type))
1367413679 return false;
1367513680
......@@ -13681,7 +13686,7 @@ static bool ir_resolve_unsigned(IrAnalyze *ira, IrInstruction *value, ZigType *i
1368113686 if (type_is_invalid(value->value.type))
1368213687 return false;
1368313688
13684 IrInstruction *casted_value = ir_implicit_cast(ira, value, value, int_type);
13689 IrInstruction *casted_value = ir_implicit_cast(ira, value, int_type);
1368513690 if (type_is_invalid(casted_value->value.type))
1368613691 return false;
1368713692
......@@ -13701,7 +13706,7 @@ static bool ir_resolve_bool(IrAnalyze *ira, IrInstruction *value, bool *out) {
1370113706 if (type_is_invalid(value->value.type))
1370213707 return false;
1370313708
13704 IrInstruction *casted_value = ir_implicit_cast(ira, value, value, ira->codegen->builtin_types.entry_bool);
13709 IrInstruction *casted_value = ir_implicit_cast(ira, value, ira->codegen->builtin_types.entry_bool);
1370513710 if (type_is_invalid(casted_value->value.type))
1370613711 return false;
1370713712
......@@ -13729,7 +13734,7 @@ static bool ir_resolve_atomic_order(IrAnalyze *ira, IrInstruction *value, Atomic
1372913734 assert(atomic_order_val->type->id == ZigTypeIdMetaType);
1373013735 ZigType *atomic_order_type = atomic_order_val->data.x_type;
1373113736
13732 IrInstruction *casted_value = ir_implicit_cast(ira, value, value, atomic_order_type);
13737 IrInstruction *casted_value = ir_implicit_cast(ira, value, atomic_order_type);
1373313738 if (type_is_invalid(casted_value->value.type))
1373413739 return false;
1373513740
......@@ -13749,7 +13754,7 @@ static bool ir_resolve_atomic_rmw_op(IrAnalyze *ira, IrInstruction *value, Atomi
1374913754 assert(atomic_rmw_op_val->type->id == ZigTypeIdMetaType);
1375013755 ZigType *atomic_rmw_op_type = atomic_rmw_op_val->data.x_type;
1375113756
13752 IrInstruction *casted_value = ir_implicit_cast(ira, value, value, atomic_rmw_op_type);
13757 IrInstruction *casted_value = ir_implicit_cast(ira, value, atomic_rmw_op_type);
1375313758 if (type_is_invalid(casted_value->value.type))
1375413759 return false;
1375513760
......@@ -13769,7 +13774,7 @@ static bool ir_resolve_global_linkage(IrAnalyze *ira, IrInstruction *value, Glob
1376913774 assert(global_linkage_val->type->id == ZigTypeIdMetaType);
1377013775 ZigType *global_linkage_type = global_linkage_val->data.x_type;
1377113776
13772 IrInstruction *casted_value = ir_implicit_cast(ira, value, value, global_linkage_type);
13777 IrInstruction *casted_value = ir_implicit_cast(ira, value, global_linkage_type);
1377313778 if (type_is_invalid(casted_value->value.type))
1377413779 return false;
1377513780
......@@ -13789,7 +13794,7 @@ static bool ir_resolve_float_mode(IrAnalyze *ira, IrInstruction *value, FloatMod
1378913794 assert(float_mode_val->type->id == ZigTypeIdMetaType);
1379013795 ZigType *float_mode_type = float_mode_val->data.x_type;
1379113796
13792 IrInstruction *casted_value = ir_implicit_cast(ira, value, value, float_mode_type);
13797 IrInstruction *casted_value = ir_implicit_cast(ira, value, float_mode_type);
1379313798 if (type_is_invalid(casted_value->value.type))
1379413799 return false;
1379513800
......@@ -13808,7 +13813,7 @@ static Buf *ir_resolve_str(IrAnalyze *ira, IrInstruction *value) {
1380813813 ZigType *ptr_type = get_pointer_to_type_extra(ira->codegen, ira->codegen->builtin_types.entry_u8,
1380913814 true, false, PtrLenUnknown, 0, 0, 0, false);
1381013815 ZigType *str_type = get_slice_type(ira->codegen, ptr_type);
13811 IrInstruction *casted_value = ir_implicit_cast(ira, value, value, str_type);
13816 IrInstruction *casted_value = ir_implicit_cast(ira, value, str_type);
1381213817 if (type_is_invalid(casted_value->value.type))
1381313818 return nullptr;
1381413819
......@@ -13872,7 +13877,7 @@ static IrInstruction *ir_analyze_instruction_return(IrAnalyze *ira, IrInstructio
1387213877 return ir_finish_anal(ira, result);
1387313878 }
1387413879
13875 IrInstruction *casted_operand = ir_implicit_cast(ira, &instruction->base, operand, ira->explicit_return_type);
13880 IrInstruction *casted_operand = ir_implicit_cast(ira, operand, ira->explicit_return_type);
1387613881 if (type_is_invalid(casted_operand->value.type)) {
1387713882 AstNode *source_node = ira->explicit_return_type_source_node;
1387813883 if (source_node != nullptr) {
......@@ -13914,11 +13919,11 @@ static IrInstruction *ir_analyze_bin_op_bool(IrAnalyze *ira, IrInstructionBinOp
1391413919
1391513920 ZigType *bool_type = ira->codegen->builtin_types.entry_bool;
1391613921
13917 IrInstruction *casted_op1 = ir_implicit_cast(ira, &bin_op_instruction->base, op1, bool_type);
13922 IrInstruction *casted_op1 = ir_implicit_cast(ira, op1, bool_type);
1391813923 if (casted_op1 == ira->codegen->invalid_instruction)
1391913924 return ira->codegen->invalid_instruction;
1392013925
13921 IrInstruction *casted_op2 = ir_implicit_cast(ira, &bin_op_instruction->base, op2, bool_type);
13926 IrInstruction *casted_op2 = ir_implicit_cast(ira, op2, bool_type);
1392213927 if (casted_op2 == ira->codegen->invalid_instruction)
1392313928 return ira->codegen->invalid_instruction;
1392413929
......@@ -14187,11 +14192,11 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp *
1418714192 ZigType *tag_type = union_val->value.type->data.unionation.tag_type;
1418814193 assert(tag_type != nullptr);
1418914194
14190 IrInstruction *casted_union = ir_implicit_cast(ira, &bin_op_instruction->base, union_val, tag_type);
14195 IrInstruction *casted_union = ir_implicit_cast(ira, union_val, tag_type);
1419114196 if (type_is_invalid(casted_union->value.type))
1419214197 return ira->codegen->invalid_instruction;
1419314198
14194 IrInstruction *casted_val = ir_implicit_cast(ira, &bin_op_instruction->base, enum_val, tag_type);
14199 IrInstruction *casted_val = ir_implicit_cast(ira, enum_val, tag_type);
1419514200 if (type_is_invalid(casted_val->value.type))
1419614201 return ira->codegen->invalid_instruction;
1419714202
......@@ -14354,11 +14359,11 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp *
1435414359 return ira->codegen->invalid_instruction;
1435514360 }
1435614361
14357 IrInstruction *casted_op1 = ir_implicit_cast(ira, &bin_op_instruction->base, op1, resolved_type);
14362 IrInstruction *casted_op1 = ir_implicit_cast(ira, op1, resolved_type);
1435814363 if (casted_op1 == ira->codegen->invalid_instruction)
1435914364 return ira->codegen->invalid_instruction;
1436014365
14361 IrInstruction *casted_op2 = ir_implicit_cast(ira, &bin_op_instruction->base, op2, resolved_type);
14366 IrInstruction *casted_op2 = ir_implicit_cast(ira, op2, resolved_type);
1436214367 if (casted_op2 == ira->codegen->invalid_instruction)
1436314368 return ira->codegen->invalid_instruction;
1436414369
......@@ -14706,7 +14711,7 @@ static IrInstruction *ir_analyze_math_op(IrAnalyze *ira, IrInstruction *source_i
1470614711 return ira->codegen->invalid_instruction;
1470714712 }
1470814713 }
14709 return ir_implicit_cast(ira, source_instr, result_instruction, type_entry);
14714 return ir_implicit_cast(ira, result_instruction, type_entry);
1471014715}
1471114716
1471214717static IrInstruction *ir_analyze_bit_shift(IrAnalyze *ira, IrInstructionBinOp *bin_op_instruction) {
......@@ -14771,7 +14776,7 @@ static IrInstruction *ir_analyze_bit_shift(IrAnalyze *ira, IrInstructionBinOp *b
1477114776 }
1477214777 }
1477314778
14774 casted_op2 = ir_implicit_cast(ira, &bin_op_instruction->base, op2, shift_amt_type);
14779 casted_op2 = ir_implicit_cast(ira, op2, shift_amt_type);
1477514780 if (casted_op2 == ira->codegen->invalid_instruction)
1477614781 return ira->codegen->invalid_instruction;
1477714782 }
......@@ -14880,7 +14885,7 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp
1488014885
1488114886 // look for pointer math
1488214887 if (is_pointer_arithmetic_allowed(op1->value.type, op_id)) {
14883 IrInstruction *casted_op2 = ir_implicit_cast(ira, &instruction->base, op2, ira->codegen->builtin_types.entry_usize);
14888 IrInstruction *casted_op2 = ir_implicit_cast(ira, op2, ira->codegen->builtin_types.entry_usize);
1488414889 if (type_is_invalid(casted_op2->value.type))
1488514890 return ira->codegen->invalid_instruction;
1488614891
......@@ -15016,7 +15021,7 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp
1501615021 ok = bigint_cmp(&rem_result, &mod_result) == CmpEQ;
1501715022 }
1501815023 } else {
15019 IrInstruction *casted_op2 = ir_implicit_cast(ira, &instruction->base, op2, resolved_type);
15024 IrInstruction *casted_op2 = ir_implicit_cast(ira, op2, resolved_type);
1502015025 if (casted_op2 == ira->codegen->invalid_instruction)
1502115026 return ira->codegen->invalid_instruction;
1502215027
......@@ -15080,11 +15085,11 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp
1508015085 }
1508115086 }
1508215087
15083 IrInstruction *casted_op1 = ir_implicit_cast(ira, &instruction->base, op1, resolved_type);
15088 IrInstruction *casted_op1 = ir_implicit_cast(ira, op1, resolved_type);
1508415089 if (casted_op1 == ira->codegen->invalid_instruction)
1508515090 return ira->codegen->invalid_instruction;
1508615091
15087 IrInstruction *casted_op2 = ir_implicit_cast(ira, &instruction->base, op2, resolved_type);
15092 IrInstruction *casted_op2 = ir_implicit_cast(ira, op2, resolved_type);
1508815093 if (casted_op2 == ira->codegen->invalid_instruction)
1508915094 return ira->codegen->invalid_instruction;
1509015095
......@@ -16297,7 +16302,7 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe
1629716302 // In this case we can pointer cast the result location.
1629816303 IrInstruction *casted_value;
1629916304 if (value != nullptr) {
16300 casted_value = ir_implicit_cast(ira, value, value, dest_type);
16305 casted_value = ir_implicit_cast(ira, value, dest_type);
1630116306 } else {
1630216307 casted_value = nullptr;
1630316308 }
......@@ -16588,7 +16593,7 @@ static IrInstruction *get_async_call_result_loc(IrAnalyze *ira, IrInstructionCal
1658816593 // Result location will be inside the async frame.
1658916594 return nullptr;
1659016595 }
16591 return ir_implicit_cast(ira, ret_ptr_uncasted, ret_ptr_uncasted, get_pointer_to_type(ira->codegen, fn_ret_type, false));
16596 return ir_implicit_cast(ira, ret_ptr_uncasted, get_pointer_to_type(ira->codegen, fn_ret_type, false));
1659216597}
1659316598
1659416599static IrInstruction *ir_analyze_async_call(IrAnalyze *ira, IrInstructionCallSrc *call_instruction, ZigFn *fn_entry,
......@@ -16625,7 +16630,7 @@ static IrInstruction *ir_analyze_async_call(IrAnalyze *ira, IrInstructionCallSrc
1662516630 if (type_is_invalid(result_loc->value.type) || instr_is_unreachable(result_loc)) {
1662616631 return result_loc;
1662716632 }
16628 result_loc = ir_implicit_cast(ira, &call_instruction->base, result_loc, get_pointer_to_type(ira->codegen, frame_type, false));
16633 result_loc = ir_implicit_cast(ira, result_loc, get_pointer_to_type(ira->codegen, frame_type, false));
1662916634 if (type_is_invalid(result_loc->value.type))
1663016635 return ira->codegen->invalid_instruction;
1663116636 return &ir_build_call_gen(ira, &call_instruction->base, fn_entry, fn_ref, arg_count,
......@@ -16646,7 +16651,7 @@ static bool ir_analyze_fn_call_inline_arg(IrAnalyze *ira, AstNode *fn_proto_node
1664616651 if (type_is_invalid(param_type))
1664716652 return false;
1664816653
16649 casted_arg = ir_implicit_cast(ira, arg, arg, param_type);
16654 casted_arg = ir_implicit_cast(ira, arg, param_type);
1665016655 if (type_is_invalid(casted_arg->value.type))
1665116656 return false;
1665216657 } else {
......@@ -16686,7 +16691,7 @@ static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_nod
1668616691 if (type_is_invalid(param_type))
1668716692 return false;
1668816693
16689 casted_arg = ir_implicit_cast(ira, arg, arg, param_type);
16694 casted_arg = ir_implicit_cast(ira, arg, param_type);
1669016695 if (type_is_invalid(casted_arg->value.type))
1669116696 return false;
1669216697 } else {
......@@ -16927,7 +16932,7 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source
1692716932 }
1692816933
1692916934 ZigType *child_type = ptr->value.type->data.pointer.child_type;
16930 IrInstruction *value = ir_implicit_cast(ira, uncasted_value, uncasted_value, child_type);
16935 IrInstruction *value = ir_implicit_cast(ira, uncasted_value, child_type);
1693116936 if (value == ira->codegen->invalid_instruction)
1693216937 return ira->codegen->invalid_instruction;
1693316938
......@@ -17044,13 +17049,13 @@ static IrInstruction *analyze_casted_new_stack(IrAnalyze *ira, IrInstructionCall
1704417049 {
1704517050 ZigType *needed_frame_type = get_pointer_to_type(ira->codegen,
1704617051 get_fn_frame_type(ira->codegen, fn_entry), false);
17047 return ir_implicit_cast(ira, &call_instruction->base, new_stack, needed_frame_type);
17052 return ir_implicit_cast(ira, new_stack, needed_frame_type);
1704817053 } else {
1704917054 ZigType *u8_ptr = get_pointer_to_type_extra(ira->codegen, ira->codegen->builtin_types.entry_u8,
1705017055 false, false, PtrLenUnknown, target_fn_align(ira->codegen->zig_target), 0, 0, false);
1705117056 ZigType *u8_slice = get_slice_type(ira->codegen, u8_ptr);
1705217057 ira->codegen->need_frame_size_prefix_data = true;
17053 return ir_implicit_cast(ira, &call_instruction->base, new_stack, u8_slice);
17058 return ir_implicit_cast(ira, new_stack, u8_slice);
1705417059 }
1705517060}
1705617061
......@@ -17524,7 +17529,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c
1752417529 return ira->codegen->invalid_instruction;
1752517530 }
1752617531
17527 IrInstruction *casted_arg = ir_implicit_cast(ira, first_arg, first_arg, param_type);
17532 IrInstruction *casted_arg = ir_implicit_cast(ira, first_arg, param_type);
1752817533 if (type_is_invalid(casted_arg->value.type))
1752917534 return ira->codegen->invalid_instruction;
1753017535
......@@ -17559,7 +17564,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c
1755917564 ZigType *param_type = fn_type_id->param_info[next_arg_index].type;
1756017565 if (type_is_invalid(param_type))
1756117566 return ira->codegen->invalid_instruction;
17562 casted_arg = ir_implicit_cast(ira, arg_tuple_arg, arg_tuple_arg, param_type);
17567 casted_arg = ir_implicit_cast(ira, arg_tuple_arg, param_type);
1756317568 if (type_is_invalid(casted_arg->value.type))
1756417569 return ira->codegen->invalid_instruction;
1756517570 } else {
......@@ -17575,7 +17580,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c
1757517580 ZigType *param_type = fn_type_id->param_info[next_arg_index].type;
1757617581 if (type_is_invalid(param_type))
1757717582 return ira->codegen->invalid_instruction;
17578 casted_arg = ir_implicit_cast(ira, old_arg, old_arg, param_type);
17583 casted_arg = ir_implicit_cast(ira, old_arg, param_type);
1757917584 if (type_is_invalid(casted_arg->value.type))
1758017585 return ira->codegen->invalid_instruction;
1758117586 } else {
......@@ -18007,7 +18012,7 @@ static IrInstruction *ir_analyze_instruction_cond_br(IrAnalyze *ira, IrInstructi
1800718012 return ir_unreach_error(ira);
1800818013
1800918014 ZigType *bool_type = ira->codegen->builtin_types.entry_bool;
18010 IrInstruction *casted_condition = ir_implicit_cast(ira, &cond_br_instruction->base, condition, bool_type);
18015 IrInstruction *casted_condition = ir_implicit_cast(ira, condition, bool_type);
1801118016 if (type_is_invalid(casted_condition->value.type))
1801218017 return ir_unreach_error(ira);
1801318018
......@@ -18257,7 +18262,7 @@ skip_resolve_peer_types:
1825718262 ir_assert(predecessor->instruction_list.length != 0, &phi_instruction->base);
1825818263 IrInstruction *branch_instruction = predecessor->instruction_list.pop();
1825918264 ir_set_cursor_at_end(&ira->new_irb, predecessor);
18260 IrInstruction *casted_value = ir_implicit_cast(ira, new_value, new_value, resolved_type);
18265 IrInstruction *casted_value = ir_implicit_cast(ira, new_value, resolved_type);
1826118266 if (type_is_invalid(casted_value->value.type)) {
1826218267 return ira->codegen->invalid_instruction;
1826318268 }
......@@ -18443,7 +18448,7 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct
1844318448 array_type->data.structure.resolve_status == ResolveStatusBeingInferred)
1844418449 {
1844518450 ZigType *usize = ira->codegen->builtin_types.entry_usize;
18446 IrInstruction *casted_elem_index = ir_implicit_cast(ira, elem_index, elem_index, usize);
18451 IrInstruction *casted_elem_index = ir_implicit_cast(ira, elem_index, usize);
1844718452 if (casted_elem_index == ira->codegen->invalid_instruction)
1844818453 return ira->codegen->invalid_instruction;
1844918454 ir_assert(instr_is_comptime(casted_elem_index), &elem_ptr_instruction->base);
......@@ -18458,7 +18463,7 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct
1845818463 }
1845918464
1846018465 ZigType *usize = ira->codegen->builtin_types.entry_usize;
18461 IrInstruction *casted_elem_index = ir_implicit_cast(ira, elem_index, elem_index, usize);
18466 IrInstruction *casted_elem_index = ir_implicit_cast(ira, elem_index, usize);
1846218467 if (casted_elem_index == ira->codegen->invalid_instruction)
1846318468 return ira->codegen->invalid_instruction;
1846418469
......@@ -19832,7 +19837,7 @@ static IrInstruction *ir_analyze_instruction_array_type(IrAnalyze *ira,
1983219837 IrInstruction *uncasted_sentinel = array_type_instruction->sentinel->child;
1983319838 if (type_is_invalid(uncasted_sentinel->value.type))
1983419839 return ira->codegen->invalid_instruction;
19835 IrInstruction *sentinel = ir_implicit_cast(ira, &array_type_instruction->base, uncasted_sentinel, child_type);
19840 IrInstruction *sentinel = ir_implicit_cast(ira, uncasted_sentinel, child_type);
1983619841 if (type_is_invalid(sentinel->value.type))
1983719842 return ira->codegen->invalid_instruction;
1983819843 sentinel_val = ir_resolve_const(ira, sentinel, UndefBad);
......@@ -20106,7 +20111,7 @@ static IrInstruction *ir_analyze_instruction_ctz(IrAnalyze *ira, IrInstructionCt
2010620111 if (type_is_invalid(int_type))
2010720112 return ira->codegen->invalid_instruction;
2010820113
20109 IrInstruction *op = ir_implicit_cast(ira, &instruction->base, instruction->op->child, int_type);
20114 IrInstruction *op = ir_implicit_cast(ira, instruction->op->child, int_type);
2011020115 if (type_is_invalid(op->value.type))
2011120116 return ira->codegen->invalid_instruction;
2011220117
......@@ -20135,7 +20140,7 @@ static IrInstruction *ir_analyze_instruction_clz(IrAnalyze *ira, IrInstructionCl
2013520140 if (type_is_invalid(int_type))
2013620141 return ira->codegen->invalid_instruction;
2013720142
20138 IrInstruction *op = ir_implicit_cast(ira, &instruction->base, instruction->op->child, int_type);
20143 IrInstruction *op = ir_implicit_cast(ira, instruction->op->child, int_type);
2013920144 if (type_is_invalid(op->value.type))
2014020145 return ira->codegen->invalid_instruction;
2014120146
......@@ -20164,7 +20169,7 @@ static IrInstruction *ir_analyze_instruction_pop_count(IrAnalyze *ira, IrInstruc
2016420169 if (type_is_invalid(int_type))
2016520170 return ira->codegen->invalid_instruction;
2016620171
20167 IrInstruction *op = ir_implicit_cast(ira, &instruction->base, instruction->op->child, int_type);
20172 IrInstruction *op = ir_implicit_cast(ira, instruction->op->child, int_type);
2016820173 if (type_is_invalid(op->value.type))
2016920174 return ira->codegen->invalid_instruction;
2017020175
......@@ -20274,7 +20279,7 @@ static IrInstruction *ir_analyze_instruction_switch_br(IrAnalyze *ira,
2027420279 return ir_unreach_error(ira);
2027520280 }
2027620281
20277 IrInstruction *casted_case_value = ir_implicit_cast(ira, case_value, case_value, target_value->value.type);
20282 IrInstruction *casted_case_value = ir_implicit_cast(ira, case_value, target_value->value.type);
2027820283 if (type_is_invalid(casted_case_value->value.type))
2027920284 return ir_unreach_error(ira);
2028020285
......@@ -20324,7 +20329,7 @@ static IrInstruction *ir_analyze_instruction_switch_br(IrAnalyze *ira,
2032420329 continue;
2032520330 }
2032620331
20327 IrInstruction *casted_new_value = ir_implicit_cast(ira, new_value, new_value, target_value->value.type);
20332 IrInstruction *casted_new_value = ir_implicit_cast(ira, new_value, target_value->value.type);
2032820333 if (type_is_invalid(casted_new_value->value.type))
2032920334 continue;
2033020335
......@@ -20494,7 +20499,7 @@ static IrInstruction *ir_analyze_instruction_switch_var(IrAnalyze *ira, IrInstru
2049420499 if (type_is_invalid(first_prong_value->value.type))
2049520500 return ira->codegen->invalid_instruction;
2049620501
20497 IrInstruction *first_casted_prong_value = ir_implicit_cast(ira, &instruction->base, first_prong_value, enum_type);
20502 IrInstruction *first_casted_prong_value = ir_implicit_cast(ira, first_prong_value, enum_type);
2049820503 if (type_is_invalid(first_casted_prong_value->value.type))
2049920504 return ira->codegen->invalid_instruction;
2050020505
......@@ -20510,7 +20515,7 @@ static IrInstruction *ir_analyze_instruction_switch_var(IrAnalyze *ira, IrInstru
2051020515 if (type_is_invalid(this_prong_inst->value.type))
2051120516 return ira->codegen->invalid_instruction;
2051220517
20513 IrInstruction *this_casted_prong_value = ir_implicit_cast(ira, &instruction->base, this_prong_inst, enum_type);
20518 IrInstruction *this_casted_prong_value = ir_implicit_cast(ira, this_prong_inst, enum_type);
2051420519 if (type_is_invalid(this_casted_prong_value->value.type))
2051520520 return ira->codegen->invalid_instruction;
2051620521
......@@ -21130,7 +21135,7 @@ static IrInstruction *ir_analyze_instruction_err_name(IrAnalyze *ira, IrInstruct
2113021135 if (type_is_invalid(value->value.type))
2113121136 return ira->codegen->invalid_instruction;
2113221137
21133 IrInstruction *casted_value = ir_implicit_cast(ira, &instruction->base, value, ira->codegen->builtin_types.entry_global_error_set);
21138 IrInstruction *casted_value = ir_implicit_cast(ira, value, ira->codegen->builtin_types.entry_global_error_set);
2113421139 if (type_is_invalid(casted_value->value.type))
2113521140 return ira->codegen->invalid_instruction;
2113621141
......@@ -21238,7 +21243,7 @@ static IrInstruction *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira,
2123821243 field_ptr->value.type->data.pointer.is_volatile,
2123921244 PtrLenSingle,
2124021245 field_ptr_align, 0, 0, false);
21241 IrInstruction *casted_field_ptr = ir_implicit_cast(ira, &instruction->base, field_ptr, field_ptr_type);
21246 IrInstruction *casted_field_ptr = ir_implicit_cast(ira, field_ptr, field_ptr_type);
2124221247 if (type_is_invalid(casted_field_ptr->value.type))
2124321248 return ira->codegen->invalid_instruction;
2124421249
......@@ -22382,7 +22387,7 @@ static Error get_const_field_sentinel(IrAnalyze *ira, IrInstruction *source_inst
2238222387{
2238322388 ConstExprValue *field_val = get_const_field(ira, struct_value, name, field_index);
2238422389 IrInstruction *field_inst = ir_const(ira, source_instr, field_val->type);
22385 IrInstruction *casted_field_inst = ir_implicit_cast(ira, source_instr, field_inst,
22390 IrInstruction *casted_field_inst = ir_implicit_cast(ira, field_inst,
2238622391 get_optional_type(ira->codegen, elem_type));
2238722392 if (type_is_invalid(casted_field_inst->value.type))
2238822393 return ErrorSemanticAnalyzeFail;
......@@ -22529,7 +22534,7 @@ static IrInstruction *ir_analyze_instruction_type(IrAnalyze *ira, IrInstructionT
2252922534 if (type_is_invalid(type_info_ir->value.type))
2253022535 return ira->codegen->invalid_instruction;
2253122536
22532 IrInstruction *casted_ir = ir_implicit_cast(ira, &instruction->base, type_info_ir, ir_type_info_get_type(ira, nullptr, nullptr));
22537 IrInstruction *casted_ir = ir_implicit_cast(ira, type_info_ir, ir_type_info_get_type(ira, nullptr, nullptr));
2253322538 if (type_is_invalid(casted_ir->value.type))
2253422539 return ira->codegen->invalid_instruction;
2253522540
......@@ -22890,7 +22895,7 @@ static IrInstruction *ir_analyze_instruction_cmpxchg(IrAnalyze *ira, IrInstructi
2289022895
2289122896 // TODO let this be volatile
2289222897 ZigType *ptr_type = get_pointer_to_type(ira->codegen, operand_type, false);
22893 IrInstruction *casted_ptr = ir_implicit_cast(ira, &instruction->base, ptr, ptr_type);
22898 IrInstruction *casted_ptr = ir_implicit_cast(ira, ptr, ptr_type);
2289422899 if (type_is_invalid(casted_ptr->value.type))
2289522900 return ira->codegen->invalid_instruction;
2289622901
......@@ -22918,11 +22923,11 @@ static IrInstruction *ir_analyze_instruction_cmpxchg(IrAnalyze *ira, IrInstructi
2291822923 if (!ir_resolve_atomic_order(ira, failure_order_value, &failure_order))
2291922924 return ira->codegen->invalid_instruction;
2292022925
22921 IrInstruction *casted_cmp_value = ir_implicit_cast(ira, &instruction->base, cmp_value, operand_type);
22926 IrInstruction *casted_cmp_value = ir_implicit_cast(ira, cmp_value, operand_type);
2292222927 if (type_is_invalid(casted_cmp_value->value.type))
2292322928 return ira->codegen->invalid_instruction;
2292422929
22925 IrInstruction *casted_new_value = ir_implicit_cast(ira, &instruction->base, new_value, operand_type);
22930 IrInstruction *casted_new_value = ir_implicit_cast(ira, new_value, operand_type);
2292622931 if (type_is_invalid(casted_new_value->value.type))
2292722932 return ira->codegen->invalid_instruction;
2292822933
......@@ -23016,7 +23021,7 @@ static IrInstruction *ir_analyze_instruction_truncate(IrAnalyze *ira, IrInstruct
2301623021 }
2301723022
2301823023 if (dest_type->id == ZigTypeIdComptimeInt) {
23019 return ir_implicit_cast(ira, &instruction->base, target, dest_type);
23024 return ir_implicit_cast(ira, target, dest_type);
2302023025 }
2302123026
2302223027 if (instr_is_comptime(target)) {
......@@ -23073,7 +23078,7 @@ static IrInstruction *ir_analyze_instruction_int_cast(IrAnalyze *ira, IrInstruct
2307323078 }
2307423079
2307523080 if (instr_is_comptime(target)) {
23076 return ir_implicit_cast(ira, &instruction->base, target, dest_type);
23081 return ir_implicit_cast(ira, target, dest_type);
2307723082 }
2307823083
2307923084 if (dest_type->id == ZigTypeIdComptimeInt) {
......@@ -23201,7 +23206,7 @@ static IrInstruction *ir_analyze_instruction_from_bytes(IrAnalyze *ira, IrInstru
2320123206 src_ptr_align, 0, 0, false);
2320223207 ZigType *u8_slice = get_slice_type(ira->codegen, u8_ptr);
2320323208
23204 IrInstruction *casted_value = ir_implicit_cast(ira, &instruction->base, target, u8_slice);
23209 IrInstruction *casted_value = ir_implicit_cast(ira, target, u8_slice);
2320523210 if (type_is_invalid(casted_value->value.type))
2320623211 return ira->codegen->invalid_instruction;
2320723212
......@@ -23350,7 +23355,7 @@ static IrInstruction *ir_analyze_instruction_float_to_int(IrAnalyze *ira, IrInst
2335023355 return ira->codegen->invalid_instruction;
2335123356
2335223357 if (target->value.type->id == ZigTypeIdComptimeInt) {
23353 return ir_implicit_cast(ira, &instruction->base, target, dest_type);
23358 return ir_implicit_cast(ira, target, dest_type);
2335423359 }
2335523360
2335623361 if (target->value.type->id != ZigTypeIdFloat && target->value.type->id != ZigTypeIdComptimeFloat) {
......@@ -23371,7 +23376,7 @@ static IrInstruction *ir_analyze_instruction_err_to_int(IrAnalyze *ira, IrInstru
2337123376 if (target->value.type->id == ZigTypeIdErrorSet) {
2337223377 casted_target = target;
2337323378 } else {
23374 casted_target = ir_implicit_cast(ira, &instruction->base, target, ira->codegen->builtin_types.entry_global_error_set);
23379 casted_target = ir_implicit_cast(ira, target, ira->codegen->builtin_types.entry_global_error_set);
2337523380 if (type_is_invalid(casted_target->value.type))
2337623381 return ira->codegen->invalid_instruction;
2337723382 }
......@@ -23384,7 +23389,7 @@ static IrInstruction *ir_analyze_instruction_int_to_err(IrAnalyze *ira, IrInstru
2338423389 if (type_is_invalid(target->value.type))
2338523390 return ira->codegen->invalid_instruction;
2338623391
23387 IrInstruction *casted_target = ir_implicit_cast(ira, &instruction->base, target, ira->codegen->err_tag_type);
23392 IrInstruction *casted_target = ir_implicit_cast(ira, target, ira->codegen->err_tag_type);
2338823393 if (type_is_invalid(casted_target->value.type))
2338923394 return ira->codegen->invalid_instruction;
2339023395
......@@ -23459,7 +23464,7 @@ static IrInstruction *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInstruction *s
2345923464 buf_ptr(&mask->value.type->name)));
2346023465 return ira->codegen->invalid_instruction;
2346123466 }
23462 mask = ir_implicit_cast(ira, source_instr, mask, get_vector_type(ira->codegen, len_mask,
23467 mask = ir_implicit_cast(ira, mask, get_vector_type(ira->codegen, len_mask,
2346323468 ira->codegen->builtin_types.entry_i32));
2346423469 if (type_is_invalid(mask->value.type))
2346523470 return ira->codegen->invalid_instruction;
......@@ -23502,7 +23507,7 @@ static IrInstruction *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInstruction *s
2350223507 len_a = len_b;
2350323508 a = ir_const_undef(ira, a, get_vector_type(ira->codegen, len_a, scalar_type));
2350423509 } else {
23505 a = ir_implicit_cast(ira, source_instr, a, get_vector_type(ira->codegen, len_a, scalar_type));
23510 a = ir_implicit_cast(ira, a, get_vector_type(ira->codegen, len_a, scalar_type));
2350623511 if (type_is_invalid(a->value.type))
2350723512 return ira->codegen->invalid_instruction;
2350823513 }
......@@ -23511,7 +23516,7 @@ static IrInstruction *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInstruction *s
2351123516 len_b = len_a;
2351223517 b = ir_const_undef(ira, b, get_vector_type(ira->codegen, len_b, scalar_type));
2351323518 } else {
23514 b = ir_implicit_cast(ira, source_instr, b, get_vector_type(ira->codegen, len_b, scalar_type));
23519 b = ir_implicit_cast(ira, b, get_vector_type(ira->codegen, len_b, scalar_type));
2351523520 if (type_is_invalid(b->value.type))
2351623521 return ira->codegen->invalid_instruction;
2351723522 }
......@@ -23687,7 +23692,7 @@ static IrInstruction *ir_analyze_instruction_bool_not(IrAnalyze *ira, IrInstruct
2368723692
2368823693 ZigType *bool_type = ira->codegen->builtin_types.entry_bool;
2368923694
23690 IrInstruction *casted_value = ir_implicit_cast(ira, &instruction->base, value, bool_type);
23695 IrInstruction *casted_value = ir_implicit_cast(ira, value, bool_type);
2369123696 if (type_is_invalid(casted_value->value.type))
2369223697 return ira->codegen->invalid_instruction;
2369323698
......@@ -23736,15 +23741,15 @@ static IrInstruction *ir_analyze_instruction_memset(IrAnalyze *ira, IrInstructio
2373623741 ZigType *u8_ptr = get_pointer_to_type_extra(ira->codegen, u8, false, dest_is_volatile,
2373723742 PtrLenUnknown, dest_align, 0, 0, false);
2373823743
23739 IrInstruction *casted_dest_ptr = ir_implicit_cast(ira, &instruction->base, dest_ptr, u8_ptr);
23744 IrInstruction *casted_dest_ptr = ir_implicit_cast(ira, dest_ptr, u8_ptr);
2374023745 if (type_is_invalid(casted_dest_ptr->value.type))
2374123746 return ira->codegen->invalid_instruction;
2374223747
23743 IrInstruction *casted_byte = ir_implicit_cast(ira, &instruction->base, byte_value, u8);
23748 IrInstruction *casted_byte = ir_implicit_cast(ira, byte_value, u8);
2374423749 if (type_is_invalid(casted_byte->value.type))
2374523750 return ira->codegen->invalid_instruction;
2374623751
23747 IrInstruction *casted_count = ir_implicit_cast(ira, &instruction->base, count_value, usize);
23752 IrInstruction *casted_count = ir_implicit_cast(ira, count_value, usize);
2374823753 if (type_is_invalid(casted_count->value.type))
2374923754 return ira->codegen->invalid_instruction;
2375023755
......@@ -23871,15 +23876,15 @@ static IrInstruction *ir_analyze_instruction_memcpy(IrAnalyze *ira, IrInstructio
2387123876 ZigType *u8_ptr_const = get_pointer_to_type_extra(ira->codegen, u8, true, src_is_volatile,
2387223877 PtrLenUnknown, src_align, 0, 0, false);
2387323878
23874 IrInstruction *casted_dest_ptr = ir_implicit_cast(ira, &instruction->base, dest_ptr, u8_ptr_mut);
23879 IrInstruction *casted_dest_ptr = ir_implicit_cast(ira, dest_ptr, u8_ptr_mut);
2387523880 if (type_is_invalid(casted_dest_ptr->value.type))
2387623881 return ira->codegen->invalid_instruction;
2387723882
23878 IrInstruction *casted_src_ptr = ir_implicit_cast(ira, &instruction->base, src_ptr, u8_ptr_const);
23883 IrInstruction *casted_src_ptr = ir_implicit_cast(ira, src_ptr, u8_ptr_const);
2387923884 if (type_is_invalid(casted_src_ptr->value.type))
2388023885 return ira->codegen->invalid_instruction;
2388123886
23882 IrInstruction *casted_count = ir_implicit_cast(ira, &instruction->base, count_value, usize);
23887 IrInstruction *casted_count = ir_implicit_cast(ira, count_value, usize);
2388323888 if (type_is_invalid(casted_count->value.type))
2388423889 return ira->codegen->invalid_instruction;
2388523890
......@@ -24019,7 +24024,7 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction
2401924024 return ira->codegen->invalid_instruction;
2402024025
2402124026 ZigType *usize = ira->codegen->builtin_types.entry_usize;
24022 IrInstruction *casted_start = ir_implicit_cast(ira, &instruction->base, start, usize);
24027 IrInstruction *casted_start = ir_implicit_cast(ira, start, usize);
2402324028 if (type_is_invalid(casted_start->value.type))
2402424029 return ira->codegen->invalid_instruction;
2402524030
......@@ -24028,7 +24033,7 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction
2402824033 end = instruction->end->child;
2402924034 if (type_is_invalid(end->value.type))
2403024035 return ira->codegen->invalid_instruction;
24031 end = ir_implicit_cast(ira, &instruction->base, end, usize);
24036 end = ir_implicit_cast(ira, end, usize);
2403224037 if (type_is_invalid(end->value.type))
2403324038 return ira->codegen->invalid_instruction;
2403424039 } else {
......@@ -24599,7 +24604,7 @@ static IrInstruction *ir_analyze_instruction_overflow_op(IrAnalyze *ira, IrInstr
2459924604 if (type_is_invalid(op1->value.type))
2460024605 return ira->codegen->invalid_instruction;
2460124606
24602 IrInstruction *casted_op1 = ir_implicit_cast(ira, &instruction->base, op1, dest_type);
24607 IrInstruction *casted_op1 = ir_implicit_cast(ira, op1, dest_type);
2460324608 if (type_is_invalid(casted_op1->value.type))
2460424609 return ira->codegen->invalid_instruction;
2460524610
......@@ -24611,9 +24616,9 @@ static IrInstruction *ir_analyze_instruction_overflow_op(IrAnalyze *ira, IrInstr
2461124616 if (instruction->op == IrOverflowOpShl) {
2461224617 ZigType *shift_amt_type = get_smallest_unsigned_int_type(ira->codegen,
2461324618 dest_type->data.integral.bit_count - 1);
24614 casted_op2 = ir_implicit_cast(ira, &instruction->base, op2, shift_amt_type);
24619 casted_op2 = ir_implicit_cast(ira, op2, shift_amt_type);
2461524620 } else {
24616 casted_op2 = ir_implicit_cast(ira, &instruction->base, op2, dest_type);
24621 casted_op2 = ir_implicit_cast(ira, op2, dest_type);
2461724622 }
2461824623 if (type_is_invalid(casted_op2->value.type))
2461924624 return ira->codegen->invalid_instruction;
......@@ -24635,7 +24640,7 @@ static IrInstruction *ir_analyze_instruction_overflow_op(IrAnalyze *ira, IrInstr
2463524640 expected_ptr_type = get_pointer_to_type(ira->codegen, dest_type, false);
2463624641 }
2463724642
24638 IrInstruction *casted_result_ptr = ir_implicit_cast(ira, &instruction->base, result_ptr, expected_ptr_type);
24643 IrInstruction *casted_result_ptr = ir_implicit_cast(ira, result_ptr, expected_ptr_type);
2463924644 if (type_is_invalid(casted_result_ptr->value.type))
2464024645 return ira->codegen->invalid_instruction;
2464124646
......@@ -24745,7 +24750,7 @@ static IrInstruction *ir_analyze_instruction_mul_add(IrAnalyze *ira, IrInstructi
2474524750 if (type_is_invalid(op1->value.type))
2474624751 return ira->codegen->invalid_instruction;
2474724752
24748 IrInstruction *casted_op1 = ir_implicit_cast(ira, &instruction->base, op1, expr_type);
24753 IrInstruction *casted_op1 = ir_implicit_cast(ira, op1, expr_type);
2474924754 if (type_is_invalid(casted_op1->value.type))
2475024755 return ira->codegen->invalid_instruction;
2475124756
......@@ -24753,7 +24758,7 @@ static IrInstruction *ir_analyze_instruction_mul_add(IrAnalyze *ira, IrInstructi
2475324758 if (type_is_invalid(op2->value.type))
2475424759 return ira->codegen->invalid_instruction;
2475524760
24756 IrInstruction *casted_op2 = ir_implicit_cast(ira, &instruction->base, op2, expr_type);
24761 IrInstruction *casted_op2 = ir_implicit_cast(ira, op2, expr_type);
2475724762 if (type_is_invalid(casted_op2->value.type))
2475824763 return ira->codegen->invalid_instruction;
2475924764
......@@ -24761,7 +24766,7 @@ static IrInstruction *ir_analyze_instruction_mul_add(IrAnalyze *ira, IrInstructi
2476124766 if (type_is_invalid(op3->value.type))
2476224767 return ira->codegen->invalid_instruction;
2476324768
24764 IrInstruction *casted_op3 = ir_implicit_cast(ira, &instruction->base, op3, expr_type);
24769 IrInstruction *casted_op3 = ir_implicit_cast(ira, op3, expr_type);
2476524770 if (type_is_invalid(casted_op3->value.type))
2476624771 return ira->codegen->invalid_instruction;
2476724772
......@@ -25133,14 +25138,14 @@ static IrInstruction *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira,
2513325138 IrInstruction *start_value_uncasted = range->start->child;
2513425139 if (type_is_invalid(start_value_uncasted->value.type))
2513525140 return ira->codegen->invalid_instruction;
25136 IrInstruction *start_value = ir_implicit_cast(ira, &instruction->base, start_value_uncasted, switch_type);
25141 IrInstruction *start_value = ir_implicit_cast(ira, start_value_uncasted, switch_type);
2513725142 if (type_is_invalid(start_value->value.type))
2513825143 return ira->codegen->invalid_instruction;
2513925144
2514025145 IrInstruction *end_value_uncasted = range->end->child;
2514125146 if (type_is_invalid(end_value_uncasted->value.type))
2514225147 return ira->codegen->invalid_instruction;
25143 IrInstruction *end_value = ir_implicit_cast(ira, &instruction->base, end_value_uncasted, switch_type);
25148 IrInstruction *end_value = ir_implicit_cast(ira, end_value_uncasted, switch_type);
2514425149 if (type_is_invalid(end_value->value.type))
2514525150 return ira->codegen->invalid_instruction;
2514625151
......@@ -25197,14 +25202,14 @@ static IrInstruction *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira,
2519725202 IrInstruction *start_value_uncasted = range->start->child;
2519825203 if (type_is_invalid(start_value_uncasted->value.type))
2519925204 return ira->codegen->invalid_instruction;
25200 IrInstruction *start_value = ir_implicit_cast(ira, &instruction->base, start_value_uncasted, switch_type);
25205 IrInstruction *start_value = ir_implicit_cast(ira, start_value_uncasted, switch_type);
2520125206 if (type_is_invalid(start_value->value.type))
2520225207 return ira->codegen->invalid_instruction;
2520325208
2520425209 IrInstruction *end_value_uncasted = range->end->child;
2520525210 if (type_is_invalid(end_value_uncasted->value.type))
2520625211 return ira->codegen->invalid_instruction;
25207 IrInstruction *end_value = ir_implicit_cast(ira, &instruction->base, end_value_uncasted, switch_type);
25212 IrInstruction *end_value = ir_implicit_cast(ira, end_value_uncasted, switch_type);
2520825213 if (type_is_invalid(end_value->value.type))
2520925214 return ira->codegen->invalid_instruction;
2521025215
......@@ -25255,14 +25260,14 @@ static IrInstruction *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira,
2525525260 IrInstruction *start_value = range->start->child;
2525625261 if (type_is_invalid(start_value->value.type))
2525725262 return ira->codegen->invalid_instruction;
25258 IrInstruction *casted_start_value = ir_implicit_cast(ira, &instruction->base, start_value, switch_type);
25263 IrInstruction *casted_start_value = ir_implicit_cast(ira, start_value, switch_type);
2525925264 if (type_is_invalid(casted_start_value->value.type))
2526025265 return ira->codegen->invalid_instruction;
2526125266
2526225267 IrInstruction *end_value = range->end->child;
2526325268 if (type_is_invalid(end_value->value.type))
2526425269 return ira->codegen->invalid_instruction;
25265 IrInstruction *casted_end_value = ir_implicit_cast(ira, &instruction->base, end_value, switch_type);
25270 IrInstruction *casted_end_value = ir_implicit_cast(ira, end_value, switch_type);
2526625271 if (type_is_invalid(casted_end_value->value.type))
2526725272 return ira->codegen->invalid_instruction;
2526825273
......@@ -25302,7 +25307,7 @@ static IrInstruction *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira,
2530225307
2530325308 IrInstruction *value = range->start->child;
2530425309
25305 IrInstruction *casted_value = ir_implicit_cast(ira, &instruction->base, value, switch_type);
25310 IrInstruction *casted_value = ir_implicit_cast(ira, value, switch_type);
2530625311 if (type_is_invalid(casted_value->value.type))
2530725312 return ira->codegen->invalid_instruction;
2530825313
......@@ -25363,7 +25368,7 @@ static IrInstruction *ir_analyze_instruction_panic(IrAnalyze *ira, IrInstruction
2536325368 ZigType *u8_ptr_type = get_pointer_to_type_extra(ira->codegen, ira->codegen->builtin_types.entry_u8,
2536425369 true, false, PtrLenUnknown, 0, 0, 0, false);
2536525370 ZigType *str_type = get_slice_type(ira->codegen, u8_ptr_type);
25366 IrInstruction *casted_msg = ir_implicit_cast(ira, &instruction->base, msg, str_type);
25371 IrInstruction *casted_msg = ir_implicit_cast(ira, msg, str_type);
2536725372 if (type_is_invalid(casted_msg->value.type))
2536825373 return ir_unreach_error(ira);
2536925374
......@@ -25973,7 +25978,7 @@ static IrInstruction *ir_analyze_int_to_ptr(IrAnalyze *ira, IrInstruction *sourc
2597325978 ir_assert(get_src_ptr_type(ptr_type) != nullptr, source_instr);
2597425979 ir_assert(type_has_bits(ptr_type), source_instr);
2597525980
25976 IrInstruction *casted_int = ir_implicit_cast(ira, source_instr, target, ira->codegen->builtin_types.entry_usize);
25981 IrInstruction *casted_int = ir_implicit_cast(ira, target, ira->codegen->builtin_types.entry_usize);
2597725982 if (type_is_invalid(casted_int->value.type))
2597825983 return ira->codegen->invalid_instruction;
2597925984
......@@ -26332,7 +26337,7 @@ static IrInstruction *ir_analyze_instruction_atomic_rmw(IrAnalyze *ira, IrInstru
2633226337
2633326338 // TODO let this be volatile
2633426339 ZigType *ptr_type = get_pointer_to_type(ira->codegen, operand_type, false);
26335 IrInstruction *casted_ptr = ir_implicit_cast(ira, &instruction->base, ptr_inst, ptr_type);
26340 IrInstruction *casted_ptr = ir_implicit_cast(ira, ptr_inst, ptr_type);
2633626341 if (type_is_invalid(casted_ptr->value.type))
2633726342 return ira->codegen->invalid_instruction;
2633826343
......@@ -26355,7 +26360,7 @@ static IrInstruction *ir_analyze_instruction_atomic_rmw(IrAnalyze *ira, IrInstru
2635526360 if (type_is_invalid(operand->value.type))
2635626361 return ira->codegen->invalid_instruction;
2635726362
26358 IrInstruction *casted_operand = ir_implicit_cast(ira, &instruction->base, operand, operand_type);
26363 IrInstruction *casted_operand = ir_implicit_cast(ira, operand, operand_type);
2635926364 if (type_is_invalid(casted_operand->value.type))
2636026365 return ira->codegen->invalid_instruction;
2636126366
......@@ -26394,7 +26399,7 @@ static IrInstruction *ir_analyze_instruction_atomic_load(IrAnalyze *ira, IrInstr
2639426399 return ira->codegen->invalid_instruction;
2639526400
2639626401 ZigType *ptr_type = get_pointer_to_type(ira->codegen, operand_type, true);
26397 IrInstruction *casted_ptr = ir_implicit_cast(ira, &instruction->base, ptr_inst, ptr_type);
26402 IrInstruction *casted_ptr = ir_implicit_cast(ira, ptr_inst, ptr_type);
2639826403 if (type_is_invalid(casted_ptr->value.type))
2639926404 return ira->codegen->invalid_instruction;
2640026405
......@@ -26435,7 +26440,7 @@ static IrInstruction *ir_analyze_instruction_atomic_store(IrAnalyze *ira, IrInst
2643526440 return ira->codegen->invalid_instruction;
2643626441
2643726442 ZigType *ptr_type = get_pointer_to_type(ira->codegen, operand_type, false);
26438 IrInstruction *casted_ptr = ir_implicit_cast(ira, &instruction->base, ptr_inst, ptr_type);
26443 IrInstruction *casted_ptr = ir_implicit_cast(ira, ptr_inst, ptr_type);
2643926444 if (type_is_invalid(casted_ptr->value.type))
2644026445 return ira->codegen->invalid_instruction;
2644126446
......@@ -26443,7 +26448,7 @@ static IrInstruction *ir_analyze_instruction_atomic_store(IrAnalyze *ira, IrInst
2644326448 if (type_is_invalid(value->value.type))
2644426449 return ira->codegen->invalid_instruction;
2644526450
26446 IrInstruction *casted_value = ir_implicit_cast(ira, &instruction->base, value, operand_type);
26451 IrInstruction *casted_value = ir_implicit_cast(ira, value, operand_type);
2644726452 if (type_is_invalid(casted_value->value.type))
2644826453 return ira->codegen->invalid_instruction;
2644926454
......@@ -26682,7 +26687,7 @@ static IrInstruction *ir_analyze_instruction_float_op(IrAnalyze *ira, IrInstruct
2668226687 if (type_is_invalid(op1->value.type))
2668326688 return ira->codegen->invalid_instruction;
2668426689
26685 IrInstruction *casted_op1 = ir_implicit_cast(ira, &instruction->base, op1, float_type);
26690 IrInstruction *casted_op1 = ir_implicit_cast(ira, op1, float_type);
2668626691 if (type_is_invalid(casted_op1->value.type))
2668726692 return ira->codegen->invalid_instruction;
2668826693
......@@ -26758,7 +26763,7 @@ static IrInstruction *ir_analyze_instruction_bswap(IrAnalyze *ira, IrInstruction
2675826763 bool is_vector = (vector_len != UINT32_MAX);
2675926764 ZigType *op_type = is_vector ? get_vector_type(ira->codegen, vector_len, int_type) : int_type;
2676026765
26761 IrInstruction *op = ir_implicit_cast(ira, &instruction->base, uncasted_op, op_type);
26766 IrInstruction *op = ir_implicit_cast(ira, uncasted_op, op_type);
2676226767 if (type_is_invalid(op->value.type))
2676326768 return ira->codegen->invalid_instruction;
2676426769
......@@ -26823,7 +26828,7 @@ static IrInstruction *ir_analyze_instruction_bit_reverse(IrAnalyze *ira, IrInstr
2682326828 if (type_is_invalid(int_type))
2682426829 return ira->codegen->invalid_instruction;
2682526830
26826 IrInstruction *op = ir_implicit_cast(ira, &instruction->base, instruction->op->child, int_type);
26831 IrInstruction *op = ir_implicit_cast(ira, instruction->op->child, int_type);
2682726832 if (type_is_invalid(op->value.type))
2682826833 return ira->codegen->invalid_instruction;
2682926834
......@@ -26904,7 +26909,7 @@ static IrInstruction *ir_analyze_instruction_int_to_enum(IrAnalyze *ira, IrInstr
2690426909 if (type_is_invalid(target->value.type))
2690526910 return ira->codegen->invalid_instruction;
2690626911
26907 IrInstruction *casted_target = ir_implicit_cast(ira, &instruction->base, target, tag_type);
26912 IrInstruction *casted_target = ir_implicit_cast(ira, target, tag_type);
2690826913 if (type_is_invalid(casted_target->value.type))
2690926914 return ira->codegen->invalid_instruction;
2691026915
......@@ -27023,7 +27028,7 @@ static IrInstruction *ir_analyze_instruction_implicit_cast(IrAnalyze *ira, IrIns
2702327028 ZigType *dest_type = ir_resolve_type(ira, instruction->result_loc_cast->base.source_instruction->child);
2702427029 if (type_is_invalid(dest_type))
2702527030 return ira->codegen->invalid_instruction;
27026 return ir_implicit_cast(ira, &instruction->base, operand, dest_type);
27031 return ir_implicit_cast2(ira, &instruction->base, operand, dest_type);
2702727032}
2702827033
2702927034static IrInstruction *ir_analyze_instruction_bit_cast_src(IrAnalyze *ira, IrInstructionBitCastSrc *instruction) {
......@@ -27136,7 +27141,7 @@ static IrInstruction *analyze_frame_ptr_to_anyframe_T(IrAnalyze *ira, IrInstruct
2713627141 }
2713727142
2713827143 ZigType *any_frame_type = get_any_frame_type(ira->codegen, result_type);
27139 IrInstruction *casted_frame = ir_implicit_cast(ira, source_instr, frame, any_frame_type);
27144 IrInstruction *casted_frame = ir_implicit_cast(ira, frame, any_frame_type);
2714027145 if (type_is_invalid(casted_frame->value.type))
2714127146 return ira->codegen->invalid_instruction;
2714227147
......@@ -27200,7 +27205,7 @@ static IrInstruction *ir_analyze_instruction_resume(IrAnalyze *ira, IrInstructio
2720027205 }
2720127206
2720227207 ZigType *any_frame_type = get_any_frame_type(ira->codegen, nullptr);
27203 IrInstruction *casted_frame = ir_implicit_cast(ira, &instruction->base, frame, any_frame_type);
27208 IrInstruction *casted_frame = ir_implicit_cast(ira, frame, any_frame_type);
2720427209 if (type_is_invalid(casted_frame->value.type))
2720527210 return ira->codegen->invalid_instruction;
2720627211
......@@ -28052,7 +28057,7 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ConstExprValue *val) {
2805228057 if (lazy_slice_type->sentinel != nullptr) {
2805328058 if (type_is_invalid(lazy_slice_type->sentinel->value.type))
2805428059 return ErrorSemanticAnalyzeFail;
28055 IrInstruction *sentinel = ir_implicit_cast(ira, lazy_slice_type->sentinel, lazy_slice_type->sentinel, elem_type);
28060 IrInstruction *sentinel = ir_implicit_cast(ira, lazy_slice_type->sentinel, elem_type);
2805628061 if (type_is_invalid(sentinel->value.type))
2805728062 return ErrorSemanticAnalyzeFail;
2805828063 sentinel_val = ir_resolve_const(ira, sentinel, UndefBad);
......@@ -28130,7 +28135,7 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ConstExprValue *val) {
2813028135 if (lazy_ptr_type->sentinel != nullptr) {
2813128136 if (type_is_invalid(lazy_ptr_type->sentinel->value.type))
2813228137 return ErrorSemanticAnalyzeFail;
28133 IrInstruction *sentinel = ir_implicit_cast(ira, lazy_ptr_type->sentinel, lazy_ptr_type->sentinel, elem_type);
28138 IrInstruction *sentinel = ir_implicit_cast(ira, lazy_ptr_type->sentinel, elem_type);
2813428139 if (type_is_invalid(sentinel->value.type))
2813528140 return ErrorSemanticAnalyzeFail;
2813628141 sentinel_val = ir_resolve_const(ira, sentinel, UndefBad);
test/compile_errors.zig+4-4
......@@ -11,10 +11,10 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
1111 \\ return ptr;
1212 \\}
1313 ,
14 "tmp.zig:2:5: error: expected type '[*:0]u8', found '[*:255]u8'",
15 "tmp.zig:2:5: note: destination pointer requires a terminating '0' sentinel value, but source pointer has a terminating '255' sentinel value",
16 "tmp.zig:5:5: error: expected type '[*:0]u8', found '[*]u8'",
17 "tmp.zig:5:5: note: destination pointer requires a terminating '0' sentinel value",
14 "tmp.zig:2:12: error: expected type '[*:0]u8', found '[*:255]u8'",
15 "tmp.zig:2:12: note: destination pointer requires a terminating '0' sentinel value, but source pointer has a terminating '255' sentinel value",
16 "tmp.zig:5:12: error: expected type '[*:0]u8', found '[*]u8'",
17 "tmp.zig:5:12: note: destination pointer requires a terminating '0' sentinel value",
1818 );
1919
2020 cases.add(