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 {...@@ -189,7 +189,8 @@ struct ConstCastPtrSentinel {
189static IrInstruction *ir_gen_node(IrBuilder *irb, AstNode *node, Scope *scope);189static IrInstruction *ir_gen_node(IrBuilder *irb, AstNode *node, Scope *scope);
190static IrInstruction *ir_gen_node_extra(IrBuilder *irb, AstNode *node, Scope *scope, LVal lval,190static IrInstruction *ir_gen_node_extra(IrBuilder *irb, AstNode *node, Scope *scope, LVal lval,
191 ResultLoc *result_loc);191 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,
193 IrInstruction *value, ZigType *expected_type);194 IrInstruction *value, ZigType *expected_type);
194static IrInstruction *ir_get_deref(IrAnalyze *ira, IrInstruction *source_instruction, IrInstruction *ptr,195static IrInstruction *ir_get_deref(IrAnalyze *ira, IrInstruction *source_instruction, IrInstruction *ptr,
195 ResultLoc *result_loc);196 ResultLoc *result_loc);
...@@ -11720,7 +11721,7 @@ static IrInstruction *ir_analyze_optional_wrap(IrAnalyze *ira, IrInstruction *so...@@ -11720,7 +11721,7 @@ static IrInstruction *ir_analyze_optional_wrap(IrAnalyze *ira, IrInstruction *so
1172011721
11721 if (instr_is_comptime(value)) {11722 if (instr_is_comptime(value)) {
11722 ZigType *payload_type = wanted_type->data.maybe.child_type;11723 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);
11724 if (type_is_invalid(casted_payload->value.type))11725 if (type_is_invalid(casted_payload->value.type))
11725 return ira->codegen->invalid_instruction;11726 return ira->codegen->invalid_instruction;
1172611727
...@@ -11763,7 +11764,7 @@ static IrInstruction *ir_analyze_err_wrap_payload(IrAnalyze *ira, IrInstruction...@@ -11763,7 +11764,7 @@ static IrInstruction *ir_analyze_err_wrap_payload(IrAnalyze *ira, IrInstruction
11763 ZigType *payload_type = wanted_type->data.error_union.payload_type;11764 ZigType *payload_type = wanted_type->data.error_union.payload_type;
11764 ZigType *err_set_type = wanted_type->data.error_union.err_set_type;11765 ZigType *err_set_type = wanted_type->data.error_union.err_set_type;
11765 if (instr_is_comptime(value)) {11766 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);
11767 if (type_is_invalid(casted_payload->value.type))11768 if (type_is_invalid(casted_payload->value.type))
11768 return ira->codegen->invalid_instruction;11769 return ira->codegen->invalid_instruction;
1176911770
...@@ -11883,7 +11884,7 @@ static IrInstruction *ir_analyze_err_wrap_code(IrAnalyze *ira, IrInstruction *so...@@ -11883,7 +11884,7 @@ static IrInstruction *ir_analyze_err_wrap_code(IrAnalyze *ira, IrInstruction *so
11883{11884{
11884 assert(wanted_type->id == ZigTypeIdErrorUnion);11885 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
11888 if (instr_is_comptime(casted_value)) {11889 if (instr_is_comptime(casted_value)) {
11889 ConstExprValue *val = ir_resolve_const(ira, casted_value, UndefBad);11890 ConstExprValue *val = ir_resolve_const(ira, casted_value, UndefBad);
...@@ -12068,7 +12069,7 @@ static IrInstruction *ir_analyze_enum_to_int(IrAnalyze *ira, IrInstruction *sour...@@ -12068,7 +12069,7 @@ static IrInstruction *ir_analyze_enum_to_int(IrAnalyze *ira, IrInstruction *sour
12068 enum_type = ir_resolve_union_tag_type(ira, target, target->value.type);12069 enum_type = ir_resolve_union_tag_type(ira, target, target->value.type);
12069 if (type_is_invalid(enum_type))12070 if (type_is_invalid(enum_type))
12070 return ira->codegen->invalid_instruction;12071 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);
12072 if (type_is_invalid(enum_target->value.type))12073 if (type_is_invalid(enum_target->value.type))
12073 return ira->codegen->invalid_instruction;12074 return ira->codegen->invalid_instruction;
12074 } else if (target->value.type->id == ZigTypeIdEnum) {12075 } else if (target->value.type->id == ZigTypeIdEnum) {
...@@ -12164,7 +12165,7 @@ static IrInstruction *ir_analyze_enum_to_union(IrAnalyze *ira, IrInstruction *so...@@ -12164,7 +12165,7 @@ static IrInstruction *ir_analyze_enum_to_union(IrAnalyze *ira, IrInstruction *so
12164 if ((err = type_resolve(ira->codegen, wanted_type, ResolveStatusZeroBitsKnown)))12165 if ((err = type_resolve(ira->codegen, wanted_type, ResolveStatusZeroBitsKnown)))
12165 return ira->codegen->invalid_instruction;12166 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);
12168 if (type_is_invalid(target->value.type))12169 if (type_is_invalid(target->value.type))
12169 return ira->codegen->invalid_instruction;12170 return ira->codegen->invalid_instruction;
1217012171
...@@ -13385,8 +13386,8 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst...@@ -13385,8 +13386,8 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst
13385 actual_type->data.pointer.child_type, source_node,13386 actual_type->data.pointer.child_type, source_node,
13386 !wanted_type->data.pointer.is_const).id == ConstCastResultIdOk &&13387 !wanted_type->data.pointer.is_const).id == ConstCastResultIdOk &&
13387 // `types_match_const_cast_only` only gets info for child_types13388 // `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 (!actual_type->data.pointer.is_const || wanted_type->data.pointer.is_const) &&
13389 (!wanted_type->data.pointer.is_volatile || actual_type->data.pointer.is_volatile))13390 (!actual_type->data.pointer.is_volatile || wanted_type->data.pointer.is_volatile))
13390 {13391 {
13391 if ((err = ir_cast_ptr_align(ira, source_instr, wanted_type, actual_type, value->source_node)))13392 if ((err = ir_cast_ptr_align(ira, source_instr, wanted_type, actual_type, value->source_node)))
13392 return ira->codegen->invalid_instruction;13393 return ira->codegen->invalid_instruction;
...@@ -13413,7 +13414,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst...@@ -13413,7 +13414,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst
13413 {13414 {
13414 TypeStructField *ptr_field = actual_type->data.structure.fields[slice_ptr_index];13415 TypeStructField *ptr_field = actual_type->data.structure.fields[slice_ptr_index];
13415 IrInstruction *slice_ptr = ir_analyze_struct_value_field_value(ira, source_instr, value, ptr_field);13416 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);
13417 }13418 }
13418 }13419 }
1341913420
...@@ -13516,7 +13517,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst...@@ -13516,7 +13517,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst
13516 return ira->codegen->invalid_instruction;13517 return ira->codegen->invalid_instruction;
13517}13518}
1351813519
13519static IrInstruction *ir_implicit_cast(IrAnalyze *ira, IrInstruction *source_instr,13520static IrInstruction *ir_implicit_cast2(IrAnalyze *ira, IrInstruction *value_source_instr,
13520 IrInstruction *value, ZigType *expected_type)13521 IrInstruction *value, ZigType *expected_type)
13521{13522{
13522 assert(value);13523 assert(value);
...@@ -13531,7 +13532,11 @@ static IrInstruction *ir_implicit_cast(IrAnalyze *ira, IrInstruction *source_ins...@@ -13531,7 +13532,11 @@ static IrInstruction *ir_implicit_cast(IrAnalyze *ira, IrInstruction *source_ins
13531 if (value->value.type->id == ZigTypeIdUnreachable)13532 if (value->value.type->id == ZigTypeIdUnreachable)
13532 return value;13533 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);
13535}13540}
1353613541
13537static IrInstruction *ir_get_deref(IrAnalyze *ira, IrInstruction *source_instruction, IrInstruction *ptr,13542static 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...@@ -13669,7 +13674,7 @@ static bool ir_resolve_align(IrAnalyze *ira, IrInstruction *value, ZigType *elem
13669 }13674 }
13670 }13675 }
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));
13673 if (type_is_invalid(casted_value->value.type))13678 if (type_is_invalid(casted_value->value.type))
13674 return false;13679 return false;
1367513680
...@@ -13681,7 +13686,7 @@ static bool ir_resolve_unsigned(IrAnalyze *ira, IrInstruction *value, ZigType *i...@@ -13681,7 +13686,7 @@ static bool ir_resolve_unsigned(IrAnalyze *ira, IrInstruction *value, ZigType *i
13681 if (type_is_invalid(value->value.type))13686 if (type_is_invalid(value->value.type))
13682 return false;13687 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);
13685 if (type_is_invalid(casted_value->value.type))13690 if (type_is_invalid(casted_value->value.type))
13686 return false;13691 return false;
1368713692
...@@ -13701,7 +13706,7 @@ static bool ir_resolve_bool(IrAnalyze *ira, IrInstruction *value, bool *out) {...@@ -13701,7 +13706,7 @@ static bool ir_resolve_bool(IrAnalyze *ira, IrInstruction *value, bool *out) {
13701 if (type_is_invalid(value->value.type))13706 if (type_is_invalid(value->value.type))
13702 return false;13707 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);
13705 if (type_is_invalid(casted_value->value.type))13710 if (type_is_invalid(casted_value->value.type))
13706 return false;13711 return false;
1370713712
...@@ -13729,7 +13734,7 @@ static bool ir_resolve_atomic_order(IrAnalyze *ira, IrInstruction *value, Atomic...@@ -13729,7 +13734,7 @@ static bool ir_resolve_atomic_order(IrAnalyze *ira, IrInstruction *value, Atomic
13729 assert(atomic_order_val->type->id == ZigTypeIdMetaType);13734 assert(atomic_order_val->type->id == ZigTypeIdMetaType);
13730 ZigType *atomic_order_type = atomic_order_val->data.x_type;13735 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);
13733 if (type_is_invalid(casted_value->value.type))13738 if (type_is_invalid(casted_value->value.type))
13734 return false;13739 return false;
1373513740
...@@ -13749,7 +13754,7 @@ static bool ir_resolve_atomic_rmw_op(IrAnalyze *ira, IrInstruction *value, Atomi...@@ -13749,7 +13754,7 @@ static bool ir_resolve_atomic_rmw_op(IrAnalyze *ira, IrInstruction *value, Atomi
13749 assert(atomic_rmw_op_val->type->id == ZigTypeIdMetaType);13754 assert(atomic_rmw_op_val->type->id == ZigTypeIdMetaType);
13750 ZigType *atomic_rmw_op_type = atomic_rmw_op_val->data.x_type;13755 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);
13753 if (type_is_invalid(casted_value->value.type))13758 if (type_is_invalid(casted_value->value.type))
13754 return false;13759 return false;
1375513760
...@@ -13769,7 +13774,7 @@ static bool ir_resolve_global_linkage(IrAnalyze *ira, IrInstruction *value, Glob...@@ -13769,7 +13774,7 @@ static bool ir_resolve_global_linkage(IrAnalyze *ira, IrInstruction *value, Glob
13769 assert(global_linkage_val->type->id == ZigTypeIdMetaType);13774 assert(global_linkage_val->type->id == ZigTypeIdMetaType);
13770 ZigType *global_linkage_type = global_linkage_val->data.x_type;13775 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);
13773 if (type_is_invalid(casted_value->value.type))13778 if (type_is_invalid(casted_value->value.type))
13774 return false;13779 return false;
1377513780
...@@ -13789,7 +13794,7 @@ static bool ir_resolve_float_mode(IrAnalyze *ira, IrInstruction *value, FloatMod...@@ -13789,7 +13794,7 @@ static bool ir_resolve_float_mode(IrAnalyze *ira, IrInstruction *value, FloatMod
13789 assert(float_mode_val->type->id == ZigTypeIdMetaType);13794 assert(float_mode_val->type->id == ZigTypeIdMetaType);
13790 ZigType *float_mode_type = float_mode_val->data.x_type;13795 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);
13793 if (type_is_invalid(casted_value->value.type))13798 if (type_is_invalid(casted_value->value.type))
13794 return false;13799 return false;
1379513800
...@@ -13808,7 +13813,7 @@ static Buf *ir_resolve_str(IrAnalyze *ira, IrInstruction *value) {...@@ -13808,7 +13813,7 @@ static Buf *ir_resolve_str(IrAnalyze *ira, IrInstruction *value) {
13808 ZigType *ptr_type = get_pointer_to_type_extra(ira->codegen, ira->codegen->builtin_types.entry_u8,13813 ZigType *ptr_type = get_pointer_to_type_extra(ira->codegen, ira->codegen->builtin_types.entry_u8,
13809 true, false, PtrLenUnknown, 0, 0, 0, false);13814 true, false, PtrLenUnknown, 0, 0, 0, false);
13810 ZigType *str_type = get_slice_type(ira->codegen, ptr_type);13815 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);
13812 if (type_is_invalid(casted_value->value.type))13817 if (type_is_invalid(casted_value->value.type))
13813 return nullptr;13818 return nullptr;
1381413819
...@@ -13872,7 +13877,7 @@ static IrInstruction *ir_analyze_instruction_return(IrAnalyze *ira, IrInstructio...@@ -13872,7 +13877,7 @@ static IrInstruction *ir_analyze_instruction_return(IrAnalyze *ira, IrInstructio
13872 return ir_finish_anal(ira, result);13877 return ir_finish_anal(ira, result);
13873 }13878 }
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);
13876 if (type_is_invalid(casted_operand->value.type)) {13881 if (type_is_invalid(casted_operand->value.type)) {
13877 AstNode *source_node = ira->explicit_return_type_source_node;13882 AstNode *source_node = ira->explicit_return_type_source_node;
13878 if (source_node != nullptr) {13883 if (source_node != nullptr) {
...@@ -13914,11 +13919,11 @@ static IrInstruction *ir_analyze_bin_op_bool(IrAnalyze *ira, IrInstructionBinOp...@@ -13914,11 +13919,11 @@ static IrInstruction *ir_analyze_bin_op_bool(IrAnalyze *ira, IrInstructionBinOp
1391413919
13915 ZigType *bool_type = ira->codegen->builtin_types.entry_bool;13920 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);
13918 if (casted_op1 == ira->codegen->invalid_instruction)13923 if (casted_op1 == ira->codegen->invalid_instruction)
13919 return ira->codegen->invalid_instruction;13924 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);
13922 if (casted_op2 == ira->codegen->invalid_instruction)13927 if (casted_op2 == ira->codegen->invalid_instruction)
13923 return ira->codegen->invalid_instruction;13928 return ira->codegen->invalid_instruction;
1392413929
...@@ -14187,11 +14192,11 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp *...@@ -14187,11 +14192,11 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp *
14187 ZigType *tag_type = union_val->value.type->data.unionation.tag_type;14192 ZigType *tag_type = union_val->value.type->data.unionation.tag_type;
14188 assert(tag_type != nullptr);14193 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);
14191 if (type_is_invalid(casted_union->value.type))14196 if (type_is_invalid(casted_union->value.type))
14192 return ira->codegen->invalid_instruction;14197 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);
14195 if (type_is_invalid(casted_val->value.type))14200 if (type_is_invalid(casted_val->value.type))
14196 return ira->codegen->invalid_instruction;14201 return ira->codegen->invalid_instruction;
1419714202
...@@ -14354,11 +14359,11 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp *...@@ -14354,11 +14359,11 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp *
14354 return ira->codegen->invalid_instruction;14359 return ira->codegen->invalid_instruction;
14355 }14360 }
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);
14358 if (casted_op1 == ira->codegen->invalid_instruction)14363 if (casted_op1 == ira->codegen->invalid_instruction)
14359 return ira->codegen->invalid_instruction;14364 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);
14362 if (casted_op2 == ira->codegen->invalid_instruction)14367 if (casted_op2 == ira->codegen->invalid_instruction)
14363 return ira->codegen->invalid_instruction;14368 return ira->codegen->invalid_instruction;
1436414369
...@@ -14706,7 +14711,7 @@ static IrInstruction *ir_analyze_math_op(IrAnalyze *ira, IrInstruction *source_i...@@ -14706,7 +14711,7 @@ static IrInstruction *ir_analyze_math_op(IrAnalyze *ira, IrInstruction *source_i
14706 return ira->codegen->invalid_instruction;14711 return ira->codegen->invalid_instruction;
14707 }14712 }
14708 }14713 }
14709 return ir_implicit_cast(ira, source_instr, result_instruction, type_entry);14714 return ir_implicit_cast(ira, result_instruction, type_entry);
14710}14715}
1471114716
14712static IrInstruction *ir_analyze_bit_shift(IrAnalyze *ira, IrInstructionBinOp *bin_op_instruction) {14717static 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...@@ -14771,7 +14776,7 @@ static IrInstruction *ir_analyze_bit_shift(IrAnalyze *ira, IrInstructionBinOp *b
14771 }14776 }
14772 }14777 }
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);
14775 if (casted_op2 == ira->codegen->invalid_instruction)14780 if (casted_op2 == ira->codegen->invalid_instruction)
14776 return ira->codegen->invalid_instruction;14781 return ira->codegen->invalid_instruction;
14777 }14782 }
...@@ -14880,7 +14885,7 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp...@@ -14880,7 +14885,7 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp
1488014885
14881 // look for pointer math14886 // look for pointer math
14882 if (is_pointer_arithmetic_allowed(op1->value.type, op_id)) {14887 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);
14884 if (type_is_invalid(casted_op2->value.type))14889 if (type_is_invalid(casted_op2->value.type))
14885 return ira->codegen->invalid_instruction;14890 return ira->codegen->invalid_instruction;
1488614891
...@@ -15016,7 +15021,7 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp...@@ -15016,7 +15021,7 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp
15016 ok = bigint_cmp(&rem_result, &mod_result) == CmpEQ;15021 ok = bigint_cmp(&rem_result, &mod_result) == CmpEQ;
15017 }15022 }
15018 } else {15023 } 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);
15020 if (casted_op2 == ira->codegen->invalid_instruction)15025 if (casted_op2 == ira->codegen->invalid_instruction)
15021 return ira->codegen->invalid_instruction;15026 return ira->codegen->invalid_instruction;
1502215027
...@@ -15080,11 +15085,11 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp...@@ -15080,11 +15085,11 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp
15080 }15085 }
15081 }15086 }
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);
15084 if (casted_op1 == ira->codegen->invalid_instruction)15089 if (casted_op1 == ira->codegen->invalid_instruction)
15085 return ira->codegen->invalid_instruction;15090 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);
15088 if (casted_op2 == ira->codegen->invalid_instruction)15093 if (casted_op2 == ira->codegen->invalid_instruction)
15089 return ira->codegen->invalid_instruction;15094 return ira->codegen->invalid_instruction;
1509015095
...@@ -16297,7 +16302,7 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe...@@ -16297,7 +16302,7 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe
16297 // In this case we can pointer cast the result location.16302 // In this case we can pointer cast the result location.
16298 IrInstruction *casted_value;16303 IrInstruction *casted_value;
16299 if (value != nullptr) {16304 if (value != nullptr) {
16300 casted_value = ir_implicit_cast(ira, value, value, dest_type);16305 casted_value = ir_implicit_cast(ira, value, dest_type);
16301 } else {16306 } else {
16302 casted_value = nullptr;16307 casted_value = nullptr;
16303 }16308 }
...@@ -16588,7 +16593,7 @@ static IrInstruction *get_async_call_result_loc(IrAnalyze *ira, IrInstructionCal...@@ -16588,7 +16593,7 @@ static IrInstruction *get_async_call_result_loc(IrAnalyze *ira, IrInstructionCal
16588 // Result location will be inside the async frame.16593 // Result location will be inside the async frame.
16589 return nullptr;16594 return nullptr;
16590 }16595 }
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));
16592}16597}
1659316598
16594static IrInstruction *ir_analyze_async_call(IrAnalyze *ira, IrInstructionCallSrc *call_instruction, ZigFn *fn_entry,16599static 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...@@ -16625,7 +16630,7 @@ static IrInstruction *ir_analyze_async_call(IrAnalyze *ira, IrInstructionCallSrc
16625 if (type_is_invalid(result_loc->value.type) || instr_is_unreachable(result_loc)) {16630 if (type_is_invalid(result_loc->value.type) || instr_is_unreachable(result_loc)) {
16626 return result_loc;16631 return result_loc;
16627 }16632 }
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));
16629 if (type_is_invalid(result_loc->value.type))16634 if (type_is_invalid(result_loc->value.type))
16630 return ira->codegen->invalid_instruction;16635 return ira->codegen->invalid_instruction;
16631 return &ir_build_call_gen(ira, &call_instruction->base, fn_entry, fn_ref, arg_count,16636 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...@@ -16646,7 +16651,7 @@ static bool ir_analyze_fn_call_inline_arg(IrAnalyze *ira, AstNode *fn_proto_node
16646 if (type_is_invalid(param_type))16651 if (type_is_invalid(param_type))
16647 return false;16652 return false;
1664816653
16649 casted_arg = ir_implicit_cast(ira, arg, arg, param_type);16654 casted_arg = ir_implicit_cast(ira, arg, param_type);
16650 if (type_is_invalid(casted_arg->value.type))16655 if (type_is_invalid(casted_arg->value.type))
16651 return false;16656 return false;
16652 } else {16657 } else {
...@@ -16686,7 +16691,7 @@ static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_nod...@@ -16686,7 +16691,7 @@ static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_nod
16686 if (type_is_invalid(param_type))16691 if (type_is_invalid(param_type))
16687 return false;16692 return false;
1668816693
16689 casted_arg = ir_implicit_cast(ira, arg, arg, param_type);16694 casted_arg = ir_implicit_cast(ira, arg, param_type);
16690 if (type_is_invalid(casted_arg->value.type))16695 if (type_is_invalid(casted_arg->value.type))
16691 return false;16696 return false;
16692 } else {16697 } else {
...@@ -16927,7 +16932,7 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source...@@ -16927,7 +16932,7 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source
16927 }16932 }
1692816933
16929 ZigType *child_type = ptr->value.type->data.pointer.child_type;16934 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);
16931 if (value == ira->codegen->invalid_instruction)16936 if (value == ira->codegen->invalid_instruction)
16932 return ira->codegen->invalid_instruction;16937 return ira->codegen->invalid_instruction;
1693316938
...@@ -17044,13 +17049,13 @@ static IrInstruction *analyze_casted_new_stack(IrAnalyze *ira, IrInstructionCall...@@ -17044,13 +17049,13 @@ static IrInstruction *analyze_casted_new_stack(IrAnalyze *ira, IrInstructionCall
17044 {17049 {
17045 ZigType *needed_frame_type = get_pointer_to_type(ira->codegen,17050 ZigType *needed_frame_type = get_pointer_to_type(ira->codegen,
17046 get_fn_frame_type(ira->codegen, fn_entry), false);17051 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);
17048 } else {17053 } else {
17049 ZigType *u8_ptr = get_pointer_to_type_extra(ira->codegen, ira->codegen->builtin_types.entry_u8,17054 ZigType *u8_ptr = get_pointer_to_type_extra(ira->codegen, ira->codegen->builtin_types.entry_u8,
17050 false, false, PtrLenUnknown, target_fn_align(ira->codegen->zig_target), 0, 0, false);17055 false, false, PtrLenUnknown, target_fn_align(ira->codegen->zig_target), 0, 0, false);
17051 ZigType *u8_slice = get_slice_type(ira->codegen, u8_ptr);17056 ZigType *u8_slice = get_slice_type(ira->codegen, u8_ptr);
17052 ira->codegen->need_frame_size_prefix_data = true;17057 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);
17054 }17059 }
17055}17060}
1705617061
...@@ -17524,7 +17529,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c...@@ -17524,7 +17529,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c
17524 return ira->codegen->invalid_instruction;17529 return ira->codegen->invalid_instruction;
17525 }17530 }
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);
17528 if (type_is_invalid(casted_arg->value.type))17533 if (type_is_invalid(casted_arg->value.type))
17529 return ira->codegen->invalid_instruction;17534 return ira->codegen->invalid_instruction;
1753017535
...@@ -17559,7 +17564,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c...@@ -17559,7 +17564,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c
17559 ZigType *param_type = fn_type_id->param_info[next_arg_index].type;17564 ZigType *param_type = fn_type_id->param_info[next_arg_index].type;
17560 if (type_is_invalid(param_type))17565 if (type_is_invalid(param_type))
17561 return ira->codegen->invalid_instruction;17566 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);
17563 if (type_is_invalid(casted_arg->value.type))17568 if (type_is_invalid(casted_arg->value.type))
17564 return ira->codegen->invalid_instruction;17569 return ira->codegen->invalid_instruction;
17565 } else {17570 } else {
...@@ -17575,7 +17580,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c...@@ -17575,7 +17580,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c
17575 ZigType *param_type = fn_type_id->param_info[next_arg_index].type;17580 ZigType *param_type = fn_type_id->param_info[next_arg_index].type;
17576 if (type_is_invalid(param_type))17581 if (type_is_invalid(param_type))
17577 return ira->codegen->invalid_instruction;17582 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);
17579 if (type_is_invalid(casted_arg->value.type))17584 if (type_is_invalid(casted_arg->value.type))
17580 return ira->codegen->invalid_instruction;17585 return ira->codegen->invalid_instruction;
17581 } else {17586 } else {
...@@ -18007,7 +18012,7 @@ static IrInstruction *ir_analyze_instruction_cond_br(IrAnalyze *ira, IrInstructi...@@ -18007,7 +18012,7 @@ static IrInstruction *ir_analyze_instruction_cond_br(IrAnalyze *ira, IrInstructi
18007 return ir_unreach_error(ira);18012 return ir_unreach_error(ira);
1800818013
18009 ZigType *bool_type = ira->codegen->builtin_types.entry_bool;18014 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);
18011 if (type_is_invalid(casted_condition->value.type))18016 if (type_is_invalid(casted_condition->value.type))
18012 return ir_unreach_error(ira);18017 return ir_unreach_error(ira);
1801318018
...@@ -18257,7 +18262,7 @@ skip_resolve_peer_types:...@@ -18257,7 +18262,7 @@ skip_resolve_peer_types:
18257 ir_assert(predecessor->instruction_list.length != 0, &phi_instruction->base);18262 ir_assert(predecessor->instruction_list.length != 0, &phi_instruction->base);
18258 IrInstruction *branch_instruction = predecessor->instruction_list.pop();18263 IrInstruction *branch_instruction = predecessor->instruction_list.pop();
18259 ir_set_cursor_at_end(&ira->new_irb, predecessor);18264 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);
18261 if (type_is_invalid(casted_value->value.type)) {18266 if (type_is_invalid(casted_value->value.type)) {
18262 return ira->codegen->invalid_instruction;18267 return ira->codegen->invalid_instruction;
18263 }18268 }
...@@ -18443,7 +18448,7 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct...@@ -18443,7 +18448,7 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct
18443 array_type->data.structure.resolve_status == ResolveStatusBeingInferred)18448 array_type->data.structure.resolve_status == ResolveStatusBeingInferred)
18444 {18449 {
18445 ZigType *usize = ira->codegen->builtin_types.entry_usize;18450 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);
18447 if (casted_elem_index == ira->codegen->invalid_instruction)18452 if (casted_elem_index == ira->codegen->invalid_instruction)
18448 return ira->codegen->invalid_instruction;18453 return ira->codegen->invalid_instruction;
18449 ir_assert(instr_is_comptime(casted_elem_index), &elem_ptr_instruction->base);18454 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...@@ -18458,7 +18463,7 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct
18458 }18463 }
1845918464
18460 ZigType *usize = ira->codegen->builtin_types.entry_usize;18465 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);
18462 if (casted_elem_index == ira->codegen->invalid_instruction)18467 if (casted_elem_index == ira->codegen->invalid_instruction)
18463 return ira->codegen->invalid_instruction;18468 return ira->codegen->invalid_instruction;
1846418469
...@@ -19832,7 +19837,7 @@ static IrInstruction *ir_analyze_instruction_array_type(IrAnalyze *ira,...@@ -19832,7 +19837,7 @@ static IrInstruction *ir_analyze_instruction_array_type(IrAnalyze *ira,
19832 IrInstruction *uncasted_sentinel = array_type_instruction->sentinel->child;19837 IrInstruction *uncasted_sentinel = array_type_instruction->sentinel->child;
19833 if (type_is_invalid(uncasted_sentinel->value.type))19838 if (type_is_invalid(uncasted_sentinel->value.type))
19834 return ira->codegen->invalid_instruction;19839 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);
19836 if (type_is_invalid(sentinel->value.type))19841 if (type_is_invalid(sentinel->value.type))
19837 return ira->codegen->invalid_instruction;19842 return ira->codegen->invalid_instruction;
19838 sentinel_val = ir_resolve_const(ira, sentinel, UndefBad);19843 sentinel_val = ir_resolve_const(ira, sentinel, UndefBad);
...@@ -20106,7 +20111,7 @@ static IrInstruction *ir_analyze_instruction_ctz(IrAnalyze *ira, IrInstructionCt...@@ -20106,7 +20111,7 @@ static IrInstruction *ir_analyze_instruction_ctz(IrAnalyze *ira, IrInstructionCt
20106 if (type_is_invalid(int_type))20111 if (type_is_invalid(int_type))
20107 return ira->codegen->invalid_instruction;20112 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);
20110 if (type_is_invalid(op->value.type))20115 if (type_is_invalid(op->value.type))
20111 return ira->codegen->invalid_instruction;20116 return ira->codegen->invalid_instruction;
2011220117
...@@ -20135,7 +20140,7 @@ static IrInstruction *ir_analyze_instruction_clz(IrAnalyze *ira, IrInstructionCl...@@ -20135,7 +20140,7 @@ static IrInstruction *ir_analyze_instruction_clz(IrAnalyze *ira, IrInstructionCl
20135 if (type_is_invalid(int_type))20140 if (type_is_invalid(int_type))
20136 return ira->codegen->invalid_instruction;20141 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);
20139 if (type_is_invalid(op->value.type))20144 if (type_is_invalid(op->value.type))
20140 return ira->codegen->invalid_instruction;20145 return ira->codegen->invalid_instruction;
2014120146
...@@ -20164,7 +20169,7 @@ static IrInstruction *ir_analyze_instruction_pop_count(IrAnalyze *ira, IrInstruc...@@ -20164,7 +20169,7 @@ static IrInstruction *ir_analyze_instruction_pop_count(IrAnalyze *ira, IrInstruc
20164 if (type_is_invalid(int_type))20169 if (type_is_invalid(int_type))
20165 return ira->codegen->invalid_instruction;20170 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);
20168 if (type_is_invalid(op->value.type))20173 if (type_is_invalid(op->value.type))
20169 return ira->codegen->invalid_instruction;20174 return ira->codegen->invalid_instruction;
2017020175
...@@ -20274,7 +20279,7 @@ static IrInstruction *ir_analyze_instruction_switch_br(IrAnalyze *ira,...@@ -20274,7 +20279,7 @@ static IrInstruction *ir_analyze_instruction_switch_br(IrAnalyze *ira,
20274 return ir_unreach_error(ira);20279 return ir_unreach_error(ira);
20275 }20280 }
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);
20278 if (type_is_invalid(casted_case_value->value.type))20283 if (type_is_invalid(casted_case_value->value.type))
20279 return ir_unreach_error(ira);20284 return ir_unreach_error(ira);
2028020285
...@@ -20324,7 +20329,7 @@ static IrInstruction *ir_analyze_instruction_switch_br(IrAnalyze *ira,...@@ -20324,7 +20329,7 @@ static IrInstruction *ir_analyze_instruction_switch_br(IrAnalyze *ira,
20324 continue;20329 continue;
20325 }20330 }
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);
20328 if (type_is_invalid(casted_new_value->value.type))20333 if (type_is_invalid(casted_new_value->value.type))
20329 continue;20334 continue;
2033020335
...@@ -20494,7 +20499,7 @@ static IrInstruction *ir_analyze_instruction_switch_var(IrAnalyze *ira, IrInstru...@@ -20494,7 +20499,7 @@ static IrInstruction *ir_analyze_instruction_switch_var(IrAnalyze *ira, IrInstru
20494 if (type_is_invalid(first_prong_value->value.type))20499 if (type_is_invalid(first_prong_value->value.type))
20495 return ira->codegen->invalid_instruction;20500 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);
20498 if (type_is_invalid(first_casted_prong_value->value.type))20503 if (type_is_invalid(first_casted_prong_value->value.type))
20499 return ira->codegen->invalid_instruction;20504 return ira->codegen->invalid_instruction;
2050020505
...@@ -20510,7 +20515,7 @@ static IrInstruction *ir_analyze_instruction_switch_var(IrAnalyze *ira, IrInstru...@@ -20510,7 +20515,7 @@ static IrInstruction *ir_analyze_instruction_switch_var(IrAnalyze *ira, IrInstru
20510 if (type_is_invalid(this_prong_inst->value.type))20515 if (type_is_invalid(this_prong_inst->value.type))
20511 return ira->codegen->invalid_instruction;20516 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);
20514 if (type_is_invalid(this_casted_prong_value->value.type))20519 if (type_is_invalid(this_casted_prong_value->value.type))
20515 return ira->codegen->invalid_instruction;20520 return ira->codegen->invalid_instruction;
2051620521
...@@ -21130,7 +21135,7 @@ static IrInstruction *ir_analyze_instruction_err_name(IrAnalyze *ira, IrInstruct...@@ -21130,7 +21135,7 @@ static IrInstruction *ir_analyze_instruction_err_name(IrAnalyze *ira, IrInstruct
21130 if (type_is_invalid(value->value.type))21135 if (type_is_invalid(value->value.type))
21131 return ira->codegen->invalid_instruction;21136 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);
21134 if (type_is_invalid(casted_value->value.type))21139 if (type_is_invalid(casted_value->value.type))
21135 return ira->codegen->invalid_instruction;21140 return ira->codegen->invalid_instruction;
2113621141
...@@ -21238,7 +21243,7 @@ static IrInstruction *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira,...@@ -21238,7 +21243,7 @@ static IrInstruction *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira,
21238 field_ptr->value.type->data.pointer.is_volatile,21243 field_ptr->value.type->data.pointer.is_volatile,
21239 PtrLenSingle,21244 PtrLenSingle,
21240 field_ptr_align, 0, 0, false);21245 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);
21242 if (type_is_invalid(casted_field_ptr->value.type))21247 if (type_is_invalid(casted_field_ptr->value.type))
21243 return ira->codegen->invalid_instruction;21248 return ira->codegen->invalid_instruction;
2124421249
...@@ -22382,7 +22387,7 @@ static Error get_const_field_sentinel(IrAnalyze *ira, IrInstruction *source_inst...@@ -22382,7 +22387,7 @@ static Error get_const_field_sentinel(IrAnalyze *ira, IrInstruction *source_inst
22382{22387{
22383 ConstExprValue *field_val = get_const_field(ira, struct_value, name, field_index);22388 ConstExprValue *field_val = get_const_field(ira, struct_value, name, field_index);
22384 IrInstruction *field_inst = ir_const(ira, source_instr, field_val->type);22389 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,
22386 get_optional_type(ira->codegen, elem_type));22391 get_optional_type(ira->codegen, elem_type));
22387 if (type_is_invalid(casted_field_inst->value.type))22392 if (type_is_invalid(casted_field_inst->value.type))
22388 return ErrorSemanticAnalyzeFail;22393 return ErrorSemanticAnalyzeFail;
...@@ -22529,7 +22534,7 @@ static IrInstruction *ir_analyze_instruction_type(IrAnalyze *ira, IrInstructionT...@@ -22529,7 +22534,7 @@ static IrInstruction *ir_analyze_instruction_type(IrAnalyze *ira, IrInstructionT
22529 if (type_is_invalid(type_info_ir->value.type))22534 if (type_is_invalid(type_info_ir->value.type))
22530 return ira->codegen->invalid_instruction;22535 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));
22533 if (type_is_invalid(casted_ir->value.type))22538 if (type_is_invalid(casted_ir->value.type))
22534 return ira->codegen->invalid_instruction;22539 return ira->codegen->invalid_instruction;
2253522540
...@@ -22890,7 +22895,7 @@ static IrInstruction *ir_analyze_instruction_cmpxchg(IrAnalyze *ira, IrInstructi...@@ -22890,7 +22895,7 @@ static IrInstruction *ir_analyze_instruction_cmpxchg(IrAnalyze *ira, IrInstructi
2289022895
22891 // TODO let this be volatile22896 // TODO let this be volatile
22892 ZigType *ptr_type = get_pointer_to_type(ira->codegen, operand_type, false);22897 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);
22894 if (type_is_invalid(casted_ptr->value.type))22899 if (type_is_invalid(casted_ptr->value.type))
22895 return ira->codegen->invalid_instruction;22900 return ira->codegen->invalid_instruction;
2289622901
...@@ -22918,11 +22923,11 @@ static IrInstruction *ir_analyze_instruction_cmpxchg(IrAnalyze *ira, IrInstructi...@@ -22918,11 +22923,11 @@ static IrInstruction *ir_analyze_instruction_cmpxchg(IrAnalyze *ira, IrInstructi
22918 if (!ir_resolve_atomic_order(ira, failure_order_value, &failure_order))22923 if (!ir_resolve_atomic_order(ira, failure_order_value, &failure_order))
22919 return ira->codegen->invalid_instruction;22924 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);
22922 if (type_is_invalid(casted_cmp_value->value.type))22927 if (type_is_invalid(casted_cmp_value->value.type))
22923 return ira->codegen->invalid_instruction;22928 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);
22926 if (type_is_invalid(casted_new_value->value.type))22931 if (type_is_invalid(casted_new_value->value.type))
22927 return ira->codegen->invalid_instruction;22932 return ira->codegen->invalid_instruction;
2292822933
...@@ -23016,7 +23021,7 @@ static IrInstruction *ir_analyze_instruction_truncate(IrAnalyze *ira, IrInstruct...@@ -23016,7 +23021,7 @@ static IrInstruction *ir_analyze_instruction_truncate(IrAnalyze *ira, IrInstruct
23016 }23021 }
2301723022
23018 if (dest_type->id == ZigTypeIdComptimeInt) {23023 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);
23020 }23025 }
2302123026
23022 if (instr_is_comptime(target)) {23027 if (instr_is_comptime(target)) {
...@@ -23073,7 +23078,7 @@ static IrInstruction *ir_analyze_instruction_int_cast(IrAnalyze *ira, IrInstruct...@@ -23073,7 +23078,7 @@ static IrInstruction *ir_analyze_instruction_int_cast(IrAnalyze *ira, IrInstruct
23073 }23078 }
2307423079
23075 if (instr_is_comptime(target)) {23080 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);
23077 }23082 }
2307823083
23079 if (dest_type->id == ZigTypeIdComptimeInt) {23084 if (dest_type->id == ZigTypeIdComptimeInt) {
...@@ -23201,7 +23206,7 @@ static IrInstruction *ir_analyze_instruction_from_bytes(IrAnalyze *ira, IrInstru...@@ -23201,7 +23206,7 @@ static IrInstruction *ir_analyze_instruction_from_bytes(IrAnalyze *ira, IrInstru
23201 src_ptr_align, 0, 0, false);23206 src_ptr_align, 0, 0, false);
23202 ZigType *u8_slice = get_slice_type(ira->codegen, u8_ptr);23207 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);
23205 if (type_is_invalid(casted_value->value.type))23210 if (type_is_invalid(casted_value->value.type))
23206 return ira->codegen->invalid_instruction;23211 return ira->codegen->invalid_instruction;
2320723212
...@@ -23350,7 +23355,7 @@ static IrInstruction *ir_analyze_instruction_float_to_int(IrAnalyze *ira, IrInst...@@ -23350,7 +23355,7 @@ static IrInstruction *ir_analyze_instruction_float_to_int(IrAnalyze *ira, IrInst
23350 return ira->codegen->invalid_instruction;23355 return ira->codegen->invalid_instruction;
2335123356
23352 if (target->value.type->id == ZigTypeIdComptimeInt) {23357 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);
23354 }23359 }
2335523360
23356 if (target->value.type->id != ZigTypeIdFloat && target->value.type->id != ZigTypeIdComptimeFloat) {23361 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...@@ -23371,7 +23376,7 @@ static IrInstruction *ir_analyze_instruction_err_to_int(IrAnalyze *ira, IrInstru
23371 if (target->value.type->id == ZigTypeIdErrorSet) {23376 if (target->value.type->id == ZigTypeIdErrorSet) {
23372 casted_target = target;23377 casted_target = target;
23373 } else {23378 } 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);
23375 if (type_is_invalid(casted_target->value.type))23380 if (type_is_invalid(casted_target->value.type))
23376 return ira->codegen->invalid_instruction;23381 return ira->codegen->invalid_instruction;
23377 }23382 }
...@@ -23384,7 +23389,7 @@ static IrInstruction *ir_analyze_instruction_int_to_err(IrAnalyze *ira, IrInstru...@@ -23384,7 +23389,7 @@ static IrInstruction *ir_analyze_instruction_int_to_err(IrAnalyze *ira, IrInstru
23384 if (type_is_invalid(target->value.type))23389 if (type_is_invalid(target->value.type))
23385 return ira->codegen->invalid_instruction;23390 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);
23388 if (type_is_invalid(casted_target->value.type))23393 if (type_is_invalid(casted_target->value.type))
23389 return ira->codegen->invalid_instruction;23394 return ira->codegen->invalid_instruction;
2339023395
...@@ -23459,7 +23464,7 @@ static IrInstruction *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInstruction *s...@@ -23459,7 +23464,7 @@ static IrInstruction *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInstruction *s
23459 buf_ptr(&mask->value.type->name)));23464 buf_ptr(&mask->value.type->name)));
23460 return ira->codegen->invalid_instruction;23465 return ira->codegen->invalid_instruction;
23461 }23466 }
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,
23463 ira->codegen->builtin_types.entry_i32));23468 ira->codegen->builtin_types.entry_i32));
23464 if (type_is_invalid(mask->value.type))23469 if (type_is_invalid(mask->value.type))
23465 return ira->codegen->invalid_instruction;23470 return ira->codegen->invalid_instruction;
...@@ -23502,7 +23507,7 @@ static IrInstruction *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInstruction *s...@@ -23502,7 +23507,7 @@ static IrInstruction *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInstruction *s
23502 len_a = len_b;23507 len_a = len_b;
23503 a = ir_const_undef(ira, a, get_vector_type(ira->codegen, len_a, scalar_type));23508 a = ir_const_undef(ira, a, get_vector_type(ira->codegen, len_a, scalar_type));
23504 } else {23509 } 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));
23506 if (type_is_invalid(a->value.type))23511 if (type_is_invalid(a->value.type))
23507 return ira->codegen->invalid_instruction;23512 return ira->codegen->invalid_instruction;
23508 }23513 }
...@@ -23511,7 +23516,7 @@ static IrInstruction *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInstruction *s...@@ -23511,7 +23516,7 @@ static IrInstruction *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInstruction *s
23511 len_b = len_a;23516 len_b = len_a;
23512 b = ir_const_undef(ira, b, get_vector_type(ira->codegen, len_b, scalar_type));23517 b = ir_const_undef(ira, b, get_vector_type(ira->codegen, len_b, scalar_type));
23513 } else {23518 } 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));
23515 if (type_is_invalid(b->value.type))23520 if (type_is_invalid(b->value.type))
23516 return ira->codegen->invalid_instruction;23521 return ira->codegen->invalid_instruction;
23517 }23522 }
...@@ -23687,7 +23692,7 @@ static IrInstruction *ir_analyze_instruction_bool_not(IrAnalyze *ira, IrInstruct...@@ -23687,7 +23692,7 @@ static IrInstruction *ir_analyze_instruction_bool_not(IrAnalyze *ira, IrInstruct
2368723692
23688 ZigType *bool_type = ira->codegen->builtin_types.entry_bool;23693 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);
23691 if (type_is_invalid(casted_value->value.type))23696 if (type_is_invalid(casted_value->value.type))
23692 return ira->codegen->invalid_instruction;23697 return ira->codegen->invalid_instruction;
2369323698
...@@ -23736,15 +23741,15 @@ static IrInstruction *ir_analyze_instruction_memset(IrAnalyze *ira, IrInstructio...@@ -23736,15 +23741,15 @@ static IrInstruction *ir_analyze_instruction_memset(IrAnalyze *ira, IrInstructio
23736 ZigType *u8_ptr = get_pointer_to_type_extra(ira->codegen, u8, false, dest_is_volatile,23741 ZigType *u8_ptr = get_pointer_to_type_extra(ira->codegen, u8, false, dest_is_volatile,
23737 PtrLenUnknown, dest_align, 0, 0, false);23742 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);
23740 if (type_is_invalid(casted_dest_ptr->value.type))23745 if (type_is_invalid(casted_dest_ptr->value.type))
23741 return ira->codegen->invalid_instruction;23746 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);
23744 if (type_is_invalid(casted_byte->value.type))23749 if (type_is_invalid(casted_byte->value.type))
23745 return ira->codegen->invalid_instruction;23750 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);
23748 if (type_is_invalid(casted_count->value.type))23753 if (type_is_invalid(casted_count->value.type))
23749 return ira->codegen->invalid_instruction;23754 return ira->codegen->invalid_instruction;
2375023755
...@@ -23871,15 +23876,15 @@ static IrInstruction *ir_analyze_instruction_memcpy(IrAnalyze *ira, IrInstructio...@@ -23871,15 +23876,15 @@ static IrInstruction *ir_analyze_instruction_memcpy(IrAnalyze *ira, IrInstructio
23871 ZigType *u8_ptr_const = get_pointer_to_type_extra(ira->codegen, u8, true, src_is_volatile,23876 ZigType *u8_ptr_const = get_pointer_to_type_extra(ira->codegen, u8, true, src_is_volatile,
23872 PtrLenUnknown, src_align, 0, 0, false);23877 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);
23875 if (type_is_invalid(casted_dest_ptr->value.type))23880 if (type_is_invalid(casted_dest_ptr->value.type))
23876 return ira->codegen->invalid_instruction;23881 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);
23879 if (type_is_invalid(casted_src_ptr->value.type))23884 if (type_is_invalid(casted_src_ptr->value.type))
23880 return ira->codegen->invalid_instruction;23885 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);
23883 if (type_is_invalid(casted_count->value.type))23888 if (type_is_invalid(casted_count->value.type))
23884 return ira->codegen->invalid_instruction;23889 return ira->codegen->invalid_instruction;
2388523890
...@@ -24019,7 +24024,7 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction...@@ -24019,7 +24024,7 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction
24019 return ira->codegen->invalid_instruction;24024 return ira->codegen->invalid_instruction;
2402024025
24021 ZigType *usize = ira->codegen->builtin_types.entry_usize;24026 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);
24023 if (type_is_invalid(casted_start->value.type))24028 if (type_is_invalid(casted_start->value.type))
24024 return ira->codegen->invalid_instruction;24029 return ira->codegen->invalid_instruction;
2402524030
...@@ -24028,7 +24033,7 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction...@@ -24028,7 +24033,7 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction
24028 end = instruction->end->child;24033 end = instruction->end->child;
24029 if (type_is_invalid(end->value.type))24034 if (type_is_invalid(end->value.type))
24030 return ira->codegen->invalid_instruction;24035 return ira->codegen->invalid_instruction;
24031 end = ir_implicit_cast(ira, &instruction->base, end, usize);24036 end = ir_implicit_cast(ira, end, usize);
24032 if (type_is_invalid(end->value.type))24037 if (type_is_invalid(end->value.type))
24033 return ira->codegen->invalid_instruction;24038 return ira->codegen->invalid_instruction;
24034 } else {24039 } else {
...@@ -24599,7 +24604,7 @@ static IrInstruction *ir_analyze_instruction_overflow_op(IrAnalyze *ira, IrInstr...@@ -24599,7 +24604,7 @@ static IrInstruction *ir_analyze_instruction_overflow_op(IrAnalyze *ira, IrInstr
24599 if (type_is_invalid(op1->value.type))24604 if (type_is_invalid(op1->value.type))
24600 return ira->codegen->invalid_instruction;24605 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);
24603 if (type_is_invalid(casted_op1->value.type))24608 if (type_is_invalid(casted_op1->value.type))
24604 return ira->codegen->invalid_instruction;24609 return ira->codegen->invalid_instruction;
2460524610
...@@ -24611,9 +24616,9 @@ static IrInstruction *ir_analyze_instruction_overflow_op(IrAnalyze *ira, IrInstr...@@ -24611,9 +24616,9 @@ static IrInstruction *ir_analyze_instruction_overflow_op(IrAnalyze *ira, IrInstr
24611 if (instruction->op == IrOverflowOpShl) {24616 if (instruction->op == IrOverflowOpShl) {
24612 ZigType *shift_amt_type = get_smallest_unsigned_int_type(ira->codegen,24617 ZigType *shift_amt_type = get_smallest_unsigned_int_type(ira->codegen,
24613 dest_type->data.integral.bit_count - 1);24618 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);
24615 } else {24620 } else {
24616 casted_op2 = ir_implicit_cast(ira, &instruction->base, op2, dest_type);24621 casted_op2 = ir_implicit_cast(ira, op2, dest_type);
24617 }24622 }
24618 if (type_is_invalid(casted_op2->value.type))24623 if (type_is_invalid(casted_op2->value.type))
24619 return ira->codegen->invalid_instruction;24624 return ira->codegen->invalid_instruction;
...@@ -24635,7 +24640,7 @@ static IrInstruction *ir_analyze_instruction_overflow_op(IrAnalyze *ira, IrInstr...@@ -24635,7 +24640,7 @@ static IrInstruction *ir_analyze_instruction_overflow_op(IrAnalyze *ira, IrInstr
24635 expected_ptr_type = get_pointer_to_type(ira->codegen, dest_type, false);24640 expected_ptr_type = get_pointer_to_type(ira->codegen, dest_type, false);
24636 }24641 }
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);
24639 if (type_is_invalid(casted_result_ptr->value.type))24644 if (type_is_invalid(casted_result_ptr->value.type))
24640 return ira->codegen->invalid_instruction;24645 return ira->codegen->invalid_instruction;
2464124646
...@@ -24745,7 +24750,7 @@ static IrInstruction *ir_analyze_instruction_mul_add(IrAnalyze *ira, IrInstructi...@@ -24745,7 +24750,7 @@ static IrInstruction *ir_analyze_instruction_mul_add(IrAnalyze *ira, IrInstructi
24745 if (type_is_invalid(op1->value.type))24750 if (type_is_invalid(op1->value.type))
24746 return ira->codegen->invalid_instruction;24751 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);
24749 if (type_is_invalid(casted_op1->value.type))24754 if (type_is_invalid(casted_op1->value.type))
24750 return ira->codegen->invalid_instruction;24755 return ira->codegen->invalid_instruction;
2475124756
...@@ -24753,7 +24758,7 @@ static IrInstruction *ir_analyze_instruction_mul_add(IrAnalyze *ira, IrInstructi...@@ -24753,7 +24758,7 @@ static IrInstruction *ir_analyze_instruction_mul_add(IrAnalyze *ira, IrInstructi
24753 if (type_is_invalid(op2->value.type))24758 if (type_is_invalid(op2->value.type))
24754 return ira->codegen->invalid_instruction;24759 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);
24757 if (type_is_invalid(casted_op2->value.type))24762 if (type_is_invalid(casted_op2->value.type))
24758 return ira->codegen->invalid_instruction;24763 return ira->codegen->invalid_instruction;
2475924764
...@@ -24761,7 +24766,7 @@ static IrInstruction *ir_analyze_instruction_mul_add(IrAnalyze *ira, IrInstructi...@@ -24761,7 +24766,7 @@ static IrInstruction *ir_analyze_instruction_mul_add(IrAnalyze *ira, IrInstructi
24761 if (type_is_invalid(op3->value.type))24766 if (type_is_invalid(op3->value.type))
24762 return ira->codegen->invalid_instruction;24767 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);
24765 if (type_is_invalid(casted_op3->value.type))24770 if (type_is_invalid(casted_op3->value.type))
24766 return ira->codegen->invalid_instruction;24771 return ira->codegen->invalid_instruction;
2476724772
...@@ -25133,14 +25138,14 @@ static IrInstruction *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira,...@@ -25133,14 +25138,14 @@ static IrInstruction *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira,
25133 IrInstruction *start_value_uncasted = range->start->child;25138 IrInstruction *start_value_uncasted = range->start->child;
25134 if (type_is_invalid(start_value_uncasted->value.type))25139 if (type_is_invalid(start_value_uncasted->value.type))
25135 return ira->codegen->invalid_instruction;25140 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);
25137 if (type_is_invalid(start_value->value.type))25142 if (type_is_invalid(start_value->value.type))
25138 return ira->codegen->invalid_instruction;25143 return ira->codegen->invalid_instruction;
2513925144
25140 IrInstruction *end_value_uncasted = range->end->child;25145 IrInstruction *end_value_uncasted = range->end->child;
25141 if (type_is_invalid(end_value_uncasted->value.type))25146 if (type_is_invalid(end_value_uncasted->value.type))
25142 return ira->codegen->invalid_instruction;25147 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);
25144 if (type_is_invalid(end_value->value.type))25149 if (type_is_invalid(end_value->value.type))
25145 return ira->codegen->invalid_instruction;25150 return ira->codegen->invalid_instruction;
2514625151
...@@ -25197,14 +25202,14 @@ static IrInstruction *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira,...@@ -25197,14 +25202,14 @@ static IrInstruction *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira,
25197 IrInstruction *start_value_uncasted = range->start->child;25202 IrInstruction *start_value_uncasted = range->start->child;
25198 if (type_is_invalid(start_value_uncasted->value.type))25203 if (type_is_invalid(start_value_uncasted->value.type))
25199 return ira->codegen->invalid_instruction;25204 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);
25201 if (type_is_invalid(start_value->value.type))25206 if (type_is_invalid(start_value->value.type))
25202 return ira->codegen->invalid_instruction;25207 return ira->codegen->invalid_instruction;
2520325208
25204 IrInstruction *end_value_uncasted = range->end->child;25209 IrInstruction *end_value_uncasted = range->end->child;
25205 if (type_is_invalid(end_value_uncasted->value.type))25210 if (type_is_invalid(end_value_uncasted->value.type))
25206 return ira->codegen->invalid_instruction;25211 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);
25208 if (type_is_invalid(end_value->value.type))25213 if (type_is_invalid(end_value->value.type))
25209 return ira->codegen->invalid_instruction;25214 return ira->codegen->invalid_instruction;
2521025215
...@@ -25255,14 +25260,14 @@ static IrInstruction *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira,...@@ -25255,14 +25260,14 @@ static IrInstruction *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira,
25255 IrInstruction *start_value = range->start->child;25260 IrInstruction *start_value = range->start->child;
25256 if (type_is_invalid(start_value->value.type))25261 if (type_is_invalid(start_value->value.type))
25257 return ira->codegen->invalid_instruction;25262 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);
25259 if (type_is_invalid(casted_start_value->value.type))25264 if (type_is_invalid(casted_start_value->value.type))
25260 return ira->codegen->invalid_instruction;25265 return ira->codegen->invalid_instruction;
2526125266
25262 IrInstruction *end_value = range->end->child;25267 IrInstruction *end_value = range->end->child;
25263 if (type_is_invalid(end_value->value.type))25268 if (type_is_invalid(end_value->value.type))
25264 return ira->codegen->invalid_instruction;25269 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);
25266 if (type_is_invalid(casted_end_value->value.type))25271 if (type_is_invalid(casted_end_value->value.type))
25267 return ira->codegen->invalid_instruction;25272 return ira->codegen->invalid_instruction;
2526825273
...@@ -25302,7 +25307,7 @@ static IrInstruction *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira,...@@ -25302,7 +25307,7 @@ static IrInstruction *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira,
2530225307
25303 IrInstruction *value = range->start->child;25308 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);
25306 if (type_is_invalid(casted_value->value.type))25311 if (type_is_invalid(casted_value->value.type))
25307 return ira->codegen->invalid_instruction;25312 return ira->codegen->invalid_instruction;
2530825313
...@@ -25363,7 +25368,7 @@ static IrInstruction *ir_analyze_instruction_panic(IrAnalyze *ira, IrInstruction...@@ -25363,7 +25368,7 @@ static IrInstruction *ir_analyze_instruction_panic(IrAnalyze *ira, IrInstruction
25363 ZigType *u8_ptr_type = get_pointer_to_type_extra(ira->codegen, ira->codegen->builtin_types.entry_u8,25368 ZigType *u8_ptr_type = get_pointer_to_type_extra(ira->codegen, ira->codegen->builtin_types.entry_u8,
25364 true, false, PtrLenUnknown, 0, 0, 0, false);25369 true, false, PtrLenUnknown, 0, 0, 0, false);
25365 ZigType *str_type = get_slice_type(ira->codegen, u8_ptr_type);25370 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);
25367 if (type_is_invalid(casted_msg->value.type))25372 if (type_is_invalid(casted_msg->value.type))
25368 return ir_unreach_error(ira);25373 return ir_unreach_error(ira);
2536925374
...@@ -25973,7 +25978,7 @@ static IrInstruction *ir_analyze_int_to_ptr(IrAnalyze *ira, IrInstruction *sourc...@@ -25973,7 +25978,7 @@ static IrInstruction *ir_analyze_int_to_ptr(IrAnalyze *ira, IrInstruction *sourc
25973 ir_assert(get_src_ptr_type(ptr_type) != nullptr, source_instr);25978 ir_assert(get_src_ptr_type(ptr_type) != nullptr, source_instr);
25974 ir_assert(type_has_bits(ptr_type), source_instr);25979 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);
25977 if (type_is_invalid(casted_int->value.type))25982 if (type_is_invalid(casted_int->value.type))
25978 return ira->codegen->invalid_instruction;25983 return ira->codegen->invalid_instruction;
2597925984
...@@ -26332,7 +26337,7 @@ static IrInstruction *ir_analyze_instruction_atomic_rmw(IrAnalyze *ira, IrInstru...@@ -26332,7 +26337,7 @@ static IrInstruction *ir_analyze_instruction_atomic_rmw(IrAnalyze *ira, IrInstru
2633226337
26333 // TODO let this be volatile26338 // TODO let this be volatile
26334 ZigType *ptr_type = get_pointer_to_type(ira->codegen, operand_type, false);26339 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);
26336 if (type_is_invalid(casted_ptr->value.type))26341 if (type_is_invalid(casted_ptr->value.type))
26337 return ira->codegen->invalid_instruction;26342 return ira->codegen->invalid_instruction;
2633826343
...@@ -26355,7 +26360,7 @@ static IrInstruction *ir_analyze_instruction_atomic_rmw(IrAnalyze *ira, IrInstru...@@ -26355,7 +26360,7 @@ static IrInstruction *ir_analyze_instruction_atomic_rmw(IrAnalyze *ira, IrInstru
26355 if (type_is_invalid(operand->value.type))26360 if (type_is_invalid(operand->value.type))
26356 return ira->codegen->invalid_instruction;26361 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);
26359 if (type_is_invalid(casted_operand->value.type))26364 if (type_is_invalid(casted_operand->value.type))
26360 return ira->codegen->invalid_instruction;26365 return ira->codegen->invalid_instruction;
2636126366
...@@ -26394,7 +26399,7 @@ static IrInstruction *ir_analyze_instruction_atomic_load(IrAnalyze *ira, IrInstr...@@ -26394,7 +26399,7 @@ static IrInstruction *ir_analyze_instruction_atomic_load(IrAnalyze *ira, IrInstr
26394 return ira->codegen->invalid_instruction;26399 return ira->codegen->invalid_instruction;
2639526400
26396 ZigType *ptr_type = get_pointer_to_type(ira->codegen, operand_type, true);26401 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);
26398 if (type_is_invalid(casted_ptr->value.type))26403 if (type_is_invalid(casted_ptr->value.type))
26399 return ira->codegen->invalid_instruction;26404 return ira->codegen->invalid_instruction;
2640026405
...@@ -26435,7 +26440,7 @@ static IrInstruction *ir_analyze_instruction_atomic_store(IrAnalyze *ira, IrInst...@@ -26435,7 +26440,7 @@ static IrInstruction *ir_analyze_instruction_atomic_store(IrAnalyze *ira, IrInst
26435 return ira->codegen->invalid_instruction;26440 return ira->codegen->invalid_instruction;
2643626441
26437 ZigType *ptr_type = get_pointer_to_type(ira->codegen, operand_type, false);26442 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);
26439 if (type_is_invalid(casted_ptr->value.type))26444 if (type_is_invalid(casted_ptr->value.type))
26440 return ira->codegen->invalid_instruction;26445 return ira->codegen->invalid_instruction;
2644126446
...@@ -26443,7 +26448,7 @@ static IrInstruction *ir_analyze_instruction_atomic_store(IrAnalyze *ira, IrInst...@@ -26443,7 +26448,7 @@ static IrInstruction *ir_analyze_instruction_atomic_store(IrAnalyze *ira, IrInst
26443 if (type_is_invalid(value->value.type))26448 if (type_is_invalid(value->value.type))
26444 return ira->codegen->invalid_instruction;26449 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);
26447 if (type_is_invalid(casted_value->value.type))26452 if (type_is_invalid(casted_value->value.type))
26448 return ira->codegen->invalid_instruction;26453 return ira->codegen->invalid_instruction;
2644926454
...@@ -26682,7 +26687,7 @@ static IrInstruction *ir_analyze_instruction_float_op(IrAnalyze *ira, IrInstruct...@@ -26682,7 +26687,7 @@ static IrInstruction *ir_analyze_instruction_float_op(IrAnalyze *ira, IrInstruct
26682 if (type_is_invalid(op1->value.type))26687 if (type_is_invalid(op1->value.type))
26683 return ira->codegen->invalid_instruction;26688 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);
26686 if (type_is_invalid(casted_op1->value.type))26691 if (type_is_invalid(casted_op1->value.type))
26687 return ira->codegen->invalid_instruction;26692 return ira->codegen->invalid_instruction;
2668826693
...@@ -26758,7 +26763,7 @@ static IrInstruction *ir_analyze_instruction_bswap(IrAnalyze *ira, IrInstruction...@@ -26758,7 +26763,7 @@ static IrInstruction *ir_analyze_instruction_bswap(IrAnalyze *ira, IrInstruction
26758 bool is_vector = (vector_len != UINT32_MAX);26763 bool is_vector = (vector_len != UINT32_MAX);
26759 ZigType *op_type = is_vector ? get_vector_type(ira->codegen, vector_len, int_type) : int_type;26764 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);
26762 if (type_is_invalid(op->value.type))26767 if (type_is_invalid(op->value.type))
26763 return ira->codegen->invalid_instruction;26768 return ira->codegen->invalid_instruction;
2676426769
...@@ -26823,7 +26828,7 @@ static IrInstruction *ir_analyze_instruction_bit_reverse(IrAnalyze *ira, IrInstr...@@ -26823,7 +26828,7 @@ static IrInstruction *ir_analyze_instruction_bit_reverse(IrAnalyze *ira, IrInstr
26823 if (type_is_invalid(int_type))26828 if (type_is_invalid(int_type))
26824 return ira->codegen->invalid_instruction;26829 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);
26827 if (type_is_invalid(op->value.type))26832 if (type_is_invalid(op->value.type))
26828 return ira->codegen->invalid_instruction;26833 return ira->codegen->invalid_instruction;
2682926834
...@@ -26904,7 +26909,7 @@ static IrInstruction *ir_analyze_instruction_int_to_enum(IrAnalyze *ira, IrInstr...@@ -26904,7 +26909,7 @@ static IrInstruction *ir_analyze_instruction_int_to_enum(IrAnalyze *ira, IrInstr
26904 if (type_is_invalid(target->value.type))26909 if (type_is_invalid(target->value.type))
26905 return ira->codegen->invalid_instruction;26910 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);
26908 if (type_is_invalid(casted_target->value.type))26913 if (type_is_invalid(casted_target->value.type))
26909 return ira->codegen->invalid_instruction;26914 return ira->codegen->invalid_instruction;
2691026915
...@@ -27023,7 +27028,7 @@ static IrInstruction *ir_analyze_instruction_implicit_cast(IrAnalyze *ira, IrIns...@@ -27023,7 +27028,7 @@ static IrInstruction *ir_analyze_instruction_implicit_cast(IrAnalyze *ira, IrIns
27023 ZigType *dest_type = ir_resolve_type(ira, instruction->result_loc_cast->base.source_instruction->child);27028 ZigType *dest_type = ir_resolve_type(ira, instruction->result_loc_cast->base.source_instruction->child);
27024 if (type_is_invalid(dest_type))27029 if (type_is_invalid(dest_type))
27025 return ira->codegen->invalid_instruction;27030 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);
27027}27032}
2702827033
27029static IrInstruction *ir_analyze_instruction_bit_cast_src(IrAnalyze *ira, IrInstructionBitCastSrc *instruction) {27034static 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...@@ -27136,7 +27141,7 @@ static IrInstruction *analyze_frame_ptr_to_anyframe_T(IrAnalyze *ira, IrInstruct
27136 }27141 }
2713727142
27138 ZigType *any_frame_type = get_any_frame_type(ira->codegen, result_type);27143 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);
27140 if (type_is_invalid(casted_frame->value.type))27145 if (type_is_invalid(casted_frame->value.type))
27141 return ira->codegen->invalid_instruction;27146 return ira->codegen->invalid_instruction;
2714227147
...@@ -27200,7 +27205,7 @@ static IrInstruction *ir_analyze_instruction_resume(IrAnalyze *ira, IrInstructio...@@ -27200,7 +27205,7 @@ static IrInstruction *ir_analyze_instruction_resume(IrAnalyze *ira, IrInstructio
27200 }27205 }
2720127206
27202 ZigType *any_frame_type = get_any_frame_type(ira->codegen, nullptr);27207 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);
27204 if (type_is_invalid(casted_frame->value.type))27209 if (type_is_invalid(casted_frame->value.type))
27205 return ira->codegen->invalid_instruction;27210 return ira->codegen->invalid_instruction;
2720627211
...@@ -28052,7 +28057,7 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ConstExprValue *val) {...@@ -28052,7 +28057,7 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ConstExprValue *val) {
28052 if (lazy_slice_type->sentinel != nullptr) {28057 if (lazy_slice_type->sentinel != nullptr) {
28053 if (type_is_invalid(lazy_slice_type->sentinel->value.type))28058 if (type_is_invalid(lazy_slice_type->sentinel->value.type))
28054 return ErrorSemanticAnalyzeFail;28059 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);
28056 if (type_is_invalid(sentinel->value.type))28061 if (type_is_invalid(sentinel->value.type))
28057 return ErrorSemanticAnalyzeFail;28062 return ErrorSemanticAnalyzeFail;
28058 sentinel_val = ir_resolve_const(ira, sentinel, UndefBad);28063 sentinel_val = ir_resolve_const(ira, sentinel, UndefBad);
...@@ -28130,7 +28135,7 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ConstExprValue *val) {...@@ -28130,7 +28135,7 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ConstExprValue *val) {
28130 if (lazy_ptr_type->sentinel != nullptr) {28135 if (lazy_ptr_type->sentinel != nullptr) {
28131 if (type_is_invalid(lazy_ptr_type->sentinel->value.type))28136 if (type_is_invalid(lazy_ptr_type->sentinel->value.type))
28132 return ErrorSemanticAnalyzeFail;28137 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);
28134 if (type_is_invalid(sentinel->value.type))28139 if (type_is_invalid(sentinel->value.type))
28135 return ErrorSemanticAnalyzeFail;28140 return ErrorSemanticAnalyzeFail;
28136 sentinel_val = ir_resolve_const(ira, sentinel, UndefBad);28141 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 {...@@ -11,10 +11,10 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
11 \\ return ptr;11 \\ return ptr;
12 \\}12 \\}
13 ,13 ,
14 "tmp.zig:2:5: error: expected type '[*:0]u8', found '[*:255]u8'",14 "tmp.zig:2:12: 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",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:5: error: expected type '[*:0]u8', found '[*]u8'",16 "tmp.zig:5:12: error: expected type '[*:0]u8', found '[*]u8'",
17 "tmp.zig:5:5: note: destination pointer requires a terminating '0' sentinel value",17 "tmp.zig:5:12: note: destination pointer requires a terminating '0' sentinel value",
18 );18 );
1919
20 cases.add(20 cases.add(