| ... | @@ -9771,19 +9771,13 @@ IrInstruction *ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *node | ... | @@ -9771,19 +9771,13 @@ IrInstruction *ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *node |
| 9771 | return ir_exec_const_result(codegen, analyzed_executable); | 9771 | return ir_exec_const_result(codegen, analyzed_executable); |
| 9772 | } | 9772 | } |
| 9773 | | 9773 | |
| 9774 | static ZigType *ir_resolve_type(IrAnalyze *ira, IrInstruction *type_value, ZigTypeId wanted_type) { | 9774 | static ZigType *ir_resolve_type(IrAnalyze *ira, IrInstruction *type_value) { |
| 9775 | if (type_is_invalid(type_value->value.type)) | 9775 | if (type_is_invalid(type_value->value.type)) |
| 9776 | return ira->codegen->builtin_types.entry_invalid; | 9776 | return ira->codegen->builtin_types.entry_invalid; |
| 9777 | | 9777 | |
| 9778 | const char *expected_type_str = type_id_name(ZigTypeIdMetaType); | | |
| 9779 | | | |
| 9780 | if (wanted_type != ZigTypeIdInvalid) { | | |
| 9781 | expected_type_str = type_id_name(wanted_type); | | |
| 9782 | } | | |
| 9783 | | | |
| 9784 | if (type_value->value.type->id != ZigTypeIdMetaType) { | 9778 | if (type_value->value.type->id != ZigTypeIdMetaType) { |
| 9785 | ir_add_error( ira, type_value, | 9779 | ir_add_error(ira, type_value, |
| 9786 | buf_sprintf("expected %s type, found '%s'", expected_type_str, buf_ptr(&type_value->value.type->name))); | 9780 | buf_sprintf("expected type 'type', found '%s'", buf_ptr(&type_value->value.type->name))); |
| 9787 | return ira->codegen->builtin_types.entry_invalid; | 9781 | return ira->codegen->builtin_types.entry_invalid; |
| 9788 | } | 9782 | } |
| 9789 | | 9783 | |
| ... | @@ -9792,16 +9786,35 @@ static ZigType *ir_resolve_type(IrAnalyze *ira, IrInstruction *type_value, ZigTy | ... | @@ -9792,16 +9786,35 @@ static ZigType *ir_resolve_type(IrAnalyze *ira, IrInstruction *type_value, ZigTy |
| 9792 | return ira->codegen->builtin_types.entry_invalid; | 9786 | return ira->codegen->builtin_types.entry_invalid; |
| 9793 | | 9787 | |
| 9794 | assert(const_val->data.x_type != nullptr); | 9788 | assert(const_val->data.x_type != nullptr); |
| | 9789 | return const_val->data.x_type; |
| | 9790 | } |
| 9795 | | 9791 | |
| 9796 | ZigType *out_type = const_val->data.x_type; | 9792 | static ZigType *ir_resolve_error_set_type(IrAnalyze *ira, IrInstruction *op_source, IrInstruction *type_value) { |
| | 9793 | if (type_is_invalid(type_value->value.type)) |
| | 9794 | return ira->codegen->builtin_types.entry_invalid; |
| 9797 | | 9795 | |
| 9798 | if (wanted_type != ZigTypeIdInvalid && out_type->id != wanted_type) { | 9796 | if (type_value->value.type->id != ZigTypeIdMetaType) { |
| 9799 | ir_add_error(ira, type_value, | 9797 | ErrorMsg *msg = ir_add_error(ira, type_value, |
| 9800 | buf_sprintf( "expected %s type, found '%s'", expected_type_str, buf_ptr(&out_type->name))); | 9798 | buf_sprintf("expected error set type, found '%s'", buf_ptr(&type_value->value.type->name))); |
| | 9799 | add_error_note(ira->codegen, msg, op_source->source_node, |
| | 9800 | buf_sprintf("`||` merges error sets; `or` performs boolean OR")); |
| 9801 | return ira->codegen->builtin_types.entry_invalid; | 9801 | return ira->codegen->builtin_types.entry_invalid; |
| 9802 | } | 9802 | } |
| 9803 | | 9803 | |
| 9804 | return out_type; | 9804 | ConstExprValue *const_val = ir_resolve_const(ira, type_value, UndefBad); |
| | 9805 | if (!const_val) |
| | 9806 | return ira->codegen->builtin_types.entry_invalid; |
| | 9807 | |
| | 9808 | assert(const_val->data.x_type != nullptr); |
| | 9809 | ZigType *result_type = const_val->data.x_type; |
| | 9810 | if (result_type->id != ZigTypeIdErrorSet) { |
| | 9811 | ErrorMsg *msg = ir_add_error(ira, type_value, |
| | 9812 | buf_sprintf("expected error set type, found type '%s'", buf_ptr(&result_type->name))); |
| | 9813 | add_error_note(ira->codegen, msg, op_source->source_node, |
| | 9814 | buf_sprintf("`||` merges error sets; `or` performs boolean OR")); |
| | 9815 | return ira->codegen->builtin_types.entry_invalid; |
| | 9816 | } |
| | 9817 | return result_type; |
| 9805 | } | 9818 | } |
| 9806 | | 9819 | |
| 9807 | static ZigFn *ir_resolve_fn(IrAnalyze *ira, IrInstruction *fn_value) { | 9820 | static ZigFn *ir_resolve_fn(IrAnalyze *ira, IrInstruction *fn_value) { |
| ... | @@ -11001,7 +11014,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst | ... | @@ -11001,7 +11014,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 11001 | } | 11014 | } |
| 11002 | | 11015 | |
| 11003 | ErrorMsg *parent_msg = ir_add_error_node(ira, source_instr->source_node, | 11016 | ErrorMsg *parent_msg = ir_add_error_node(ira, source_instr->source_node, |
| 11004 | buf_sprintf("expected '%s' type, found '%s'", | 11017 | buf_sprintf("expected type '%s', found '%s'", |
| 11005 | buf_ptr(&wanted_type->name), | 11018 | buf_ptr(&wanted_type->name), |
| 11006 | buf_ptr(&actual_type->name))); | 11019 | buf_ptr(&actual_type->name))); |
| 11007 | report_recursive_error(ira, source_instr->source_node, &const_cast_result, parent_msg); | 11020 | report_recursive_error(ira, source_instr->source_node, &const_cast_result, parent_msg); |
| ... | @@ -12229,7 +12242,7 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i | ... | @@ -12229,7 +12242,7 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i |
| 12229 | size_t op2_array_end; | 12242 | size_t op2_array_end; |
| 12230 | if (op2_type->id == ZigTypeIdArray) { | 12243 | if (op2_type->id == ZigTypeIdArray) { |
| 12231 | if (op2_type->data.array.child_type != child_type) { | 12244 | if (op2_type->data.array.child_type != child_type) { |
| 12232 | ir_add_error(ira, op2, buf_sprintf("expected array of '%s' type, found '%s'", | 12245 | ir_add_error(ira, op2, buf_sprintf("expected array of type '%s', found '%s'", |
| 12233 | buf_ptr(&child_type->name), | 12246 | buf_ptr(&child_type->name), |
| 12234 | buf_ptr(&op2->value.type->name))); | 12247 | buf_ptr(&op2->value.type->name))); |
| 12235 | return ira->codegen->invalid_instruction; | 12248 | return ira->codegen->invalid_instruction; |
| ... | @@ -12243,7 +12256,7 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i | ... | @@ -12243,7 +12256,7 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i |
| 12243 | op2_val->data.x_ptr.data.base_array.is_cstr) | 12256 | op2_val->data.x_ptr.data.base_array.is_cstr) |
| 12244 | { | 12257 | { |
| 12245 | if (child_type != ira->codegen->builtin_types.entry_u8) { | 12258 | if (child_type != ira->codegen->builtin_types.entry_u8) { |
| 12246 | ir_add_error(ira, op2, buf_sprintf("expected array of '%s' type, found '%s'", | 12259 | ir_add_error(ira, op2, buf_sprintf("expected array of type '%s', found '%s'", |
| 12247 | buf_ptr(&child_type->name), | 12260 | buf_ptr(&child_type->name), |
| 12248 | buf_ptr(&op2->value.type->name))); | 12261 | buf_ptr(&op2->value.type->name))); |
| 12249 | return ira->codegen->invalid_instruction; | 12262 | return ira->codegen->invalid_instruction; |
| ... | @@ -12254,7 +12267,7 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i | ... | @@ -12254,7 +12267,7 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i |
| 12254 | } else if (is_slice(op2_type)) { | 12267 | } else if (is_slice(op2_type)) { |
| 12255 | ZigType *ptr_type = op2_type->data.structure.fields[slice_ptr_index].type_entry; | 12268 | ZigType *ptr_type = op2_type->data.structure.fields[slice_ptr_index].type_entry; |
| 12256 | if (ptr_type->data.pointer.child_type != child_type) { | 12269 | if (ptr_type->data.pointer.child_type != child_type) { |
| 12257 | ir_add_error(ira, op2, buf_sprintf("expected array of '%s' type, found '%s'", | 12270 | ir_add_error(ira, op2, buf_sprintf("expected array of type '%s', found '%s'", |
| 12258 | buf_ptr(&child_type->name), | 12271 | buf_ptr(&child_type->name), |
| 12259 | buf_ptr(&op2->value.type->name))); | 12272 | buf_ptr(&op2->value.type->name))); |
| 12260 | return ira->codegen->invalid_instruction; | 12273 | return ira->codegen->invalid_instruction; |
| ... | @@ -12268,7 +12281,7 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i | ... | @@ -12268,7 +12281,7 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i |
| 12268 | op2_array_end = bigint_as_unsigned(&len_val->data.x_bigint); | 12281 | op2_array_end = bigint_as_unsigned(&len_val->data.x_bigint); |
| 12269 | } else { | 12282 | } else { |
| 12270 | ir_add_error(ira, op2, | 12283 | ir_add_error(ira, op2, |
| 12271 | buf_sprintf("expected array or C string literal type, found '%s'", buf_ptr(&op2->value.type->name))); | 12284 | buf_sprintf("expected array or C string literal, found '%s'", buf_ptr(&op2->value.type->name))); |
| 12272 | return ira->codegen->invalid_instruction; | 12285 | return ira->codegen->invalid_instruction; |
| 12273 | } | 12286 | } |
| 12274 | | 12287 | |
| ... | @@ -12403,19 +12416,11 @@ static IrInstruction *ir_analyze_array_mult(IrAnalyze *ira, IrInstructionBinOp * | ... | @@ -12403,19 +12416,11 @@ static IrInstruction *ir_analyze_array_mult(IrAnalyze *ira, IrInstructionBinOp * |
| 12403 | } | 12416 | } |
| 12404 | | 12417 | |
| 12405 | static IrInstruction *ir_analyze_merge_error_sets(IrAnalyze *ira, IrInstructionBinOp *instruction) { | 12418 | static IrInstruction *ir_analyze_merge_error_sets(IrAnalyze *ira, IrInstructionBinOp *instruction) { |
| 12406 | ZigType *op1_type = ir_resolve_type(ira, instruction->op1->child, ZigTypeIdErrorSet); | 12419 | ZigType *op1_type = ir_resolve_error_set_type(ira, &instruction->base, instruction->op1->child); |
| 12407 | if (type_is_invalid(op1_type)) { | 12420 | if (type_is_invalid(op1_type)) |
| 12408 | if (ira->codegen->errors.length != 0) { | | |
| 12409 | add_error_note( ira->codegen | | |
| 12410 | , ira->codegen->errors.last() | | |
| 12411 | , instruction->base.source_node | | |
| 12412 | , buf_sprintf("did you mean to use `or`?") | | |
| 12413 | ); | | |
| 12414 | } | | |
| 12415 | return ira->codegen->invalid_instruction; | 12421 | return ira->codegen->invalid_instruction; |
| 12416 | } | | |
| 12417 | | 12422 | |
| 12418 | ZigType *op2_type = ir_resolve_type(ira, instruction->op2->child, ZigTypeIdErrorSet); | 12423 | ZigType *op2_type = ir_resolve_error_set_type(ira, &instruction->base, instruction->op2->child); |
| 12419 | if (type_is_invalid(op2_type)) | 12424 | if (type_is_invalid(op2_type)) |
| 12420 | return ira->codegen->invalid_instruction; | 12425 | return ira->codegen->invalid_instruction; |
| 12421 | | 12426 | |
| ... | @@ -12506,7 +12511,7 @@ static IrInstruction *ir_analyze_instruction_decl_var(IrAnalyze *ira, IrInstruct | ... | @@ -12506,7 +12511,7 @@ static IrInstruction *ir_analyze_instruction_decl_var(IrAnalyze *ira, IrInstruct |
| 12506 | IrInstruction *var_type = nullptr; | 12511 | IrInstruction *var_type = nullptr; |
| 12507 | if (decl_var_instruction->var_type != nullptr) { | 12512 | if (decl_var_instruction->var_type != nullptr) { |
| 12508 | var_type = decl_var_instruction->var_type->child; | 12513 | var_type = decl_var_instruction->var_type->child; |
| 12509 | ZigType *proposed_type = ir_resolve_type(ira, var_type, ZigTypeIdInvalid); | 12514 | ZigType *proposed_type = ir_resolve_type(ira, var_type); |
| 12510 | explicit_type = validate_var_type(ira->codegen, var_type->source_node, proposed_type); | 12515 | explicit_type = validate_var_type(ira->codegen, var_type->source_node, proposed_type); |
| 12511 | if (type_is_invalid(explicit_type)) { | 12516 | if (type_is_invalid(explicit_type)) { |
| 12512 | var->value->type = ira->codegen->builtin_types.entry_invalid; | 12517 | var->value->type = ira->codegen->builtin_types.entry_invalid; |
| ... | @@ -12835,14 +12840,21 @@ static IrInstruction *ir_analyze_instruction_error_union(IrAnalyze *ira, | ... | @@ -12835,14 +12840,21 @@ static IrInstruction *ir_analyze_instruction_error_union(IrAnalyze *ira, |
| 12835 | { | 12840 | { |
| 12836 | Error err; | 12841 | Error err; |
| 12837 | | 12842 | |
| 12838 | ZigType *err_set_type = ir_resolve_type(ira, instruction->err_set->child, ZigTypeIdErrorSet); | 12843 | ZigType *err_set_type = ir_resolve_type(ira, instruction->err_set->child); |
| 12839 | if (type_is_invalid(err_set_type)) | 12844 | if (type_is_invalid(err_set_type)) |
| 12840 | return ira->codegen->invalid_instruction; | 12845 | return ira->codegen->invalid_instruction; |
| 12841 | | 12846 | |
| 12842 | ZigType *payload_type = ir_resolve_type(ira, instruction->payload->child, ZigTypeIdInvalid); | 12847 | ZigType *payload_type = ir_resolve_type(ira, instruction->payload->child); |
| 12843 | if (type_is_invalid(payload_type)) | 12848 | if (type_is_invalid(payload_type)) |
| 12844 | return ira->codegen->invalid_instruction; | 12849 | return ira->codegen->invalid_instruction; |
| 12845 | | 12850 | |
| | 12851 | if (err_set_type->id != ZigTypeIdErrorSet) { |
| | 12852 | ir_add_error(ira, instruction->err_set->child, |
| | 12853 | buf_sprintf("expected error set type, found type '%s'", |
| | 12854 | buf_ptr(&err_set_type->name))); |
| | 12855 | return ira->codegen->invalid_instruction; |
| | 12856 | } |
| | 12857 | |
| 12846 | if ((err = type_resolve(ira->codegen, payload_type, ResolveStatusSizeKnown))) | 12858 | if ((err = type_resolve(ira->codegen, payload_type, ResolveStatusSizeKnown))) |
| 12847 | return ira->codegen->invalid_instruction; | 12859 | return ira->codegen->invalid_instruction; |
| 12848 | ZigType *result_type = get_error_union_type(ira->codegen, err_set_type, payload_type); | 12860 | ZigType *result_type = get_error_union_type(ira->codegen, err_set_type, payload_type); |
| ... | @@ -12904,7 +12916,7 @@ static IrInstruction *ir_analyze_async_call(IrAnalyze *ira, IrInstructionCall *c | ... | @@ -12904,7 +12916,7 @@ static IrInstruction *ir_analyze_async_call(IrAnalyze *ira, IrInstructionCall *c |
| 12904 | ZigType *alloc_fn_type = ptr_to_alloc_fn_type->data.pointer.child_type; | 12916 | ZigType *alloc_fn_type = ptr_to_alloc_fn_type->data.pointer.child_type; |
| 12905 | if (alloc_fn_type->id != ZigTypeIdFn) { | 12917 | if (alloc_fn_type->id != ZigTypeIdFn) { |
| 12906 | ir_add_error(ira, &call_instruction->base, | 12918 | ir_add_error(ira, &call_instruction->base, |
| 12907 | buf_sprintf("expected allocation function type, found '%s'", buf_ptr(&alloc_fn_type->name))); | 12919 | buf_sprintf("expected allocation function, found '%s'", buf_ptr(&alloc_fn_type->name))); |
| 12908 | return ira->codegen->invalid_instruction; | 12920 | return ira->codegen->invalid_instruction; |
| 12909 | } | 12921 | } |
| 12910 | | 12922 | |
| ... | @@ -13696,7 +13708,7 @@ static IrInstruction *ir_analyze_instruction_call(IrAnalyze *ira, IrInstructionC | ... | @@ -13696,7 +13708,7 @@ static IrInstruction *ir_analyze_instruction_call(IrAnalyze *ira, IrInstructionC |
| 13696 | | 13708 | |
| 13697 | if (is_comptime || instr_is_comptime(fn_ref)) { | 13709 | if (is_comptime || instr_is_comptime(fn_ref)) { |
| 13698 | if (fn_ref->value.type->id == ZigTypeIdMetaType) { | 13710 | if (fn_ref->value.type->id == ZigTypeIdMetaType) { |
| 13699 | ZigType *dest_type = ir_resolve_type(ira, fn_ref, ZigTypeIdInvalid); | 13711 | ZigType *dest_type = ir_resolve_type(ira, fn_ref); |
| 13700 | if (type_is_invalid(dest_type)) | 13712 | if (type_is_invalid(dest_type)) |
| 13701 | return ira->codegen->invalid_instruction; | 13713 | return ira->codegen->invalid_instruction; |
| 13702 | | 13714 | |
| ... | @@ -13821,7 +13833,7 @@ static Error ir_read_const_ptr(IrAnalyze *ira, CodeGen *codegen, AstNode *source | ... | @@ -13821,7 +13833,7 @@ static Error ir_read_const_ptr(IrAnalyze *ira, CodeGen *codegen, AstNode *source |
| 13821 | static IrInstruction *ir_analyze_maybe(IrAnalyze *ira, IrInstructionUnOp *un_op_instruction) { | 13833 | static IrInstruction *ir_analyze_maybe(IrAnalyze *ira, IrInstructionUnOp *un_op_instruction) { |
| 13822 | Error err; | 13834 | Error err; |
| 13823 | IrInstruction *value = un_op_instruction->value->child; | 13835 | IrInstruction *value = un_op_instruction->value->child; |
| 13824 | ZigType *type_entry = ir_resolve_type(ira, value, ZigTypeIdInvalid); | 13836 | ZigType *type_entry = ir_resolve_type(ira, value); |
| 13825 | if (type_is_invalid(type_entry)) | 13837 | if (type_is_invalid(type_entry)) |
| 13826 | return ira->codegen->invalid_instruction; | 13838 | return ira->codegen->invalid_instruction; |
| 13827 | if ((err = ensure_complete_type(ira->codegen, type_entry))) | 13839 | if ((err = ensure_complete_type(ira->codegen, type_entry))) |
| ... | @@ -15304,10 +15316,16 @@ static IrInstruction *ir_analyze_instruction_ptr_type_child(IrAnalyze *ira, | ... | @@ -15304,10 +15316,16 @@ static IrInstruction *ir_analyze_instruction_ptr_type_child(IrAnalyze *ira, |
| 15304 | IrInstructionPtrTypeChild *ptr_type_child_instruction) | 15316 | IrInstructionPtrTypeChild *ptr_type_child_instruction) |
| 15305 | { | 15317 | { |
| 15306 | IrInstruction *type_value = ptr_type_child_instruction->value->child; | 15318 | IrInstruction *type_value = ptr_type_child_instruction->value->child; |
| 15307 | ZigType *type_entry = ir_resolve_type(ira, type_value, ZigTypeIdPointer); | 15319 | ZigType *type_entry = ir_resolve_type(ira, type_value); |
| 15308 | if (type_is_invalid(type_entry)) | 15320 | if (type_is_invalid(type_entry)) |
| 15309 | return ira->codegen->invalid_instruction; | 15321 | return ira->codegen->invalid_instruction; |
| 15310 | | 15322 | |
| | 15323 | if (type_entry->id != ZigTypeIdPointer) { |
| | 15324 | ir_add_error_node(ira, ptr_type_child_instruction->base.source_node, |
| | 15325 | buf_sprintf("expected pointer type, found '%s'", buf_ptr(&type_entry->name))); |
| | 15326 | return ira->codegen->invalid_instruction; |
| | 15327 | } |
| | 15328 | |
| 15311 | return ir_const_type(ira, &ptr_type_child_instruction->base, type_entry->data.pointer.child_type); | 15329 | return ir_const_type(ira, &ptr_type_child_instruction->base, type_entry->data.pointer.child_type); |
| 15312 | } | 15330 | } |
| 15313 | | 15331 | |
| ... | @@ -15460,7 +15478,7 @@ static IrInstruction *ir_analyze_instruction_slice_type(IrAnalyze *ira, | ... | @@ -15460,7 +15478,7 @@ static IrInstruction *ir_analyze_instruction_slice_type(IrAnalyze *ira, |
| 15460 | return ira->codegen->invalid_instruction; | 15478 | return ira->codegen->invalid_instruction; |
| 15461 | } | 15479 | } |
| 15462 | | 15480 | |
| 15463 | ZigType *child_type = ir_resolve_type(ira, slice_type_instruction->child_type->child, ZigTypeIdInvalid); | 15481 | ZigType *child_type = ir_resolve_type(ira, slice_type_instruction->child_type->child); |
| 15464 | if (type_is_invalid(child_type)) | 15482 | if (type_is_invalid(child_type)) |
| 15465 | return ira->codegen->invalid_instruction; | 15483 | return ira->codegen->invalid_instruction; |
| 15466 | | 15484 | |
| ... | @@ -15543,7 +15561,7 @@ static IrInstruction *ir_analyze_instruction_asm(IrAnalyze *ira, IrInstructionAs | ... | @@ -15543,7 +15561,7 @@ static IrInstruction *ir_analyze_instruction_asm(IrAnalyze *ira, IrInstructionAs |
| 15543 | AsmOutput *asm_output = asm_expr->output_list.at(i); | 15561 | AsmOutput *asm_output = asm_expr->output_list.at(i); |
| 15544 | if (asm_output->return_type) { | 15562 | if (asm_output->return_type) { |
| 15545 | output_types[i] = asm_instruction->output_types[i]->child; | 15563 | output_types[i] = asm_instruction->output_types[i]->child; |
| 15546 | return_type = ir_resolve_type(ira, output_types[i], ZigTypeIdInvalid); | 15564 | return_type = ir_resolve_type(ira, output_types[i]); |
| 15547 | if (type_is_invalid(return_type)) | 15565 | if (type_is_invalid(return_type)) |
| 15548 | return ira->codegen->invalid_instruction; | 15566 | return ira->codegen->invalid_instruction; |
| 15549 | } | 15567 | } |
| ... | @@ -15558,7 +15576,7 @@ static IrInstruction *ir_analyze_instruction_asm(IrAnalyze *ira, IrInstructionAs | ... | @@ -15558,7 +15576,7 @@ static IrInstruction *ir_analyze_instruction_asm(IrAnalyze *ira, IrInstructionAs |
| 15558 | (input_value->value.type->id == ZigTypeIdComptimeInt || | 15576 | (input_value->value.type->id == ZigTypeIdComptimeInt || |
| 15559 | input_value->value.type->id == ZigTypeIdComptimeFloat)) { | 15577 | input_value->value.type->id == ZigTypeIdComptimeFloat)) { |
| 15560 | ir_add_error_node(ira, input_value->source_node, | 15578 | ir_add_error_node(ira, input_value->source_node, |
| 15561 | buf_sprintf("expected sized integer or sized float type, found %s", buf_ptr(&input_value->value.type->name))); | 15579 | buf_sprintf("expected sized integer or sized float, found %s", buf_ptr(&input_value->value.type->name))); |
| 15562 | return ira->codegen->invalid_instruction; | 15580 | return ira->codegen->invalid_instruction; |
| 15563 | } | 15581 | } |
| 15564 | | 15582 | |
| ... | @@ -15584,7 +15602,7 @@ static IrInstruction *ir_analyze_instruction_array_type(IrAnalyze *ira, | ... | @@ -15584,7 +15602,7 @@ static IrInstruction *ir_analyze_instruction_array_type(IrAnalyze *ira, |
| 15584 | return ira->codegen->invalid_instruction; | 15602 | return ira->codegen->invalid_instruction; |
| 15585 | | 15603 | |
| 15586 | IrInstruction *child_type_value = array_type_instruction->child_type->child; | 15604 | IrInstruction *child_type_value = array_type_instruction->child_type->child; |
| 15587 | ZigType *child_type = ir_resolve_type(ira, child_type_value, ZigTypeIdInvalid); | 15605 | ZigType *child_type = ir_resolve_type(ira, child_type_value); |
| 15588 | if (type_is_invalid(child_type)) | 15606 | if (type_is_invalid(child_type)) |
| 15589 | return ira->codegen->invalid_instruction; | 15607 | return ira->codegen->invalid_instruction; |
| 15590 | switch (child_type->id) { | 15608 | switch (child_type->id) { |
| ... | @@ -15633,7 +15651,7 @@ static IrInstruction *ir_analyze_instruction_promise_type(IrAnalyze *ira, IrInst | ... | @@ -15633,7 +15651,7 @@ static IrInstruction *ir_analyze_instruction_promise_type(IrAnalyze *ira, IrInst |
| 15633 | if (instruction->payload_type == nullptr) { | 15651 | if (instruction->payload_type == nullptr) { |
| 15634 | promise_type = ira->codegen->builtin_types.entry_promise; | 15652 | promise_type = ira->codegen->builtin_types.entry_promise; |
| 15635 | } else { | 15653 | } else { |
| 15636 | ZigType *payload_type = ir_resolve_type(ira, instruction->payload_type->child, ZigTypeIdInvalid); | 15654 | ZigType *payload_type = ir_resolve_type(ira, instruction->payload_type->child); |
| 15637 | if (type_is_invalid(payload_type)) | 15655 | if (type_is_invalid(payload_type)) |
| 15638 | return ira->codegen->invalid_instruction; | 15656 | return ira->codegen->invalid_instruction; |
| 15639 | | 15657 | |
| ... | @@ -15648,7 +15666,7 @@ static IrInstruction *ir_analyze_instruction_size_of(IrAnalyze *ira, | ... | @@ -15648,7 +15666,7 @@ static IrInstruction *ir_analyze_instruction_size_of(IrAnalyze *ira, |
| 15648 | { | 15666 | { |
| 15649 | Error err; | 15667 | Error err; |
| 15650 | IrInstruction *type_value = size_of_instruction->type_value->child; | 15668 | IrInstruction *type_value = size_of_instruction->type_value->child; |
| 15651 | ZigType *type_entry = ir_resolve_type(ira, type_value, ZigTypeIdInvalid); | 15669 | ZigType *type_entry = ir_resolve_type(ira, type_value); |
| 15652 | | 15670 | |
| 15653 | if ((err = ensure_complete_type(ira->codegen, type_entry))) | 15671 | if ((err = ensure_complete_type(ira->codegen, type_entry))) |
| 15654 | return ira->codegen->invalid_instruction; | 15672 | return ira->codegen->invalid_instruction; |
| ... | @@ -16483,7 +16501,7 @@ static IrInstruction *ir_analyze_instruction_container_init_list(IrAnalyze *ira, | ... | @@ -16483,7 +16501,7 @@ static IrInstruction *ir_analyze_instruction_container_init_list(IrAnalyze *ira, |
| 16483 | | 16501 | |
| 16484 | size_t elem_count = instruction->item_count; | 16502 | size_t elem_count = instruction->item_count; |
| 16485 | if (container_type_value->value.type->id == ZigTypeIdMetaType) { | 16503 | if (container_type_value->value.type->id == ZigTypeIdMetaType) { |
| 16486 | ZigType *container_type = ir_resolve_type(ira, container_type_value, ZigTypeIdInvalid); | 16504 | ZigType *container_type = ir_resolve_type(ira, container_type_value); |
| 16487 | if (type_is_invalid(container_type)) | 16505 | if (type_is_invalid(container_type)) |
| 16488 | return ira->codegen->invalid_instruction; | 16506 | return ira->codegen->invalid_instruction; |
| 16489 | | 16507 | |
| ... | @@ -16599,7 +16617,7 @@ static IrInstruction *ir_analyze_instruction_container_init_list(IrAnalyze *ira, | ... | @@ -16599,7 +16617,7 @@ static IrInstruction *ir_analyze_instruction_container_init_list(IrAnalyze *ira, |
| 16599 | | 16617 | |
| 16600 | static IrInstruction *ir_analyze_instruction_container_init_fields(IrAnalyze *ira, IrInstructionContainerInitFields *instruction) { | 16618 | static IrInstruction *ir_analyze_instruction_container_init_fields(IrAnalyze *ira, IrInstructionContainerInitFields *instruction) { |
| 16601 | IrInstruction *container_type_value = instruction->container_type->child; | 16619 | IrInstruction *container_type_value = instruction->container_type->child; |
| 16602 | ZigType *container_type = ir_resolve_type(ira, container_type_value, ZigTypeIdInvalid); | 16620 | ZigType *container_type = ir_resolve_type(ira, container_type_value); |
| 16603 | if (type_is_invalid(container_type)) | 16621 | if (type_is_invalid(container_type)) |
| 16604 | return ira->codegen->invalid_instruction; | 16622 | return ira->codegen->invalid_instruction; |
| 16605 | | 16623 | |
| ... | @@ -16717,7 +16735,7 @@ static IrInstruction *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira, | ... | @@ -16717,7 +16735,7 @@ static IrInstruction *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira, |
| 16717 | { | 16735 | { |
| 16718 | Error err; | 16736 | Error err; |
| 16719 | IrInstruction *type_value = instruction->type_value->child; | 16737 | IrInstruction *type_value = instruction->type_value->child; |
| 16720 | ZigType *container_type = ir_resolve_type(ira, type_value, ZigTypeIdStruct); | 16738 | ZigType *container_type = ir_resolve_type(ira, type_value); |
| 16721 | if (type_is_invalid(container_type)) | 16739 | if (type_is_invalid(container_type)) |
| 16722 | return ira->codegen->invalid_instruction; | 16740 | return ira->codegen->invalid_instruction; |
| 16723 | | 16741 | |
| ... | @@ -16730,6 +16748,12 @@ static IrInstruction *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira, | ... | @@ -16730,6 +16748,12 @@ static IrInstruction *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira, |
| 16730 | if (type_is_invalid(field_ptr->value.type)) | 16748 | if (type_is_invalid(field_ptr->value.type)) |
| 16731 | return ira->codegen->invalid_instruction; | 16749 | return ira->codegen->invalid_instruction; |
| 16732 | | 16750 | |
| | 16751 | if (container_type->id != ZigTypeIdStruct) { |
| | 16752 | ir_add_error(ira, type_value, |
| | 16753 | buf_sprintf("expected struct type, found '%s'", buf_ptr(&container_type->name))); |
| | 16754 | return ira->codegen->invalid_instruction; |
| | 16755 | } |
| | 16756 | |
| 16733 | if ((err = ensure_complete_type(ira->codegen, container_type))) | 16757 | if ((err = ensure_complete_type(ira->codegen, container_type))) |
| 16734 | return ira->codegen->invalid_instruction; | 16758 | return ira->codegen->invalid_instruction; |
| 16735 | | 16759 | |
| ... | @@ -16743,7 +16767,7 @@ static IrInstruction *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira, | ... | @@ -16743,7 +16767,7 @@ static IrInstruction *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira, |
| 16743 | | 16767 | |
| 16744 | if (field_ptr->value.type->id != ZigTypeIdPointer) { | 16768 | if (field_ptr->value.type->id != ZigTypeIdPointer) { |
| 16745 | ir_add_error(ira, field_ptr, | 16769 | ir_add_error(ira, field_ptr, |
| 16746 | buf_sprintf("expected Pointer type, found '%s'", buf_ptr(&field_ptr->value.type->name))); | 16770 | buf_sprintf("expected pointer, found '%s'", buf_ptr(&field_ptr->value.type->name))); |
| 16747 | return ira->codegen->invalid_instruction; | 16771 | return ira->codegen->invalid_instruction; |
| 16748 | } | 16772 | } |
| 16749 | | 16773 | |
| ... | @@ -16802,9 +16826,9 @@ static IrInstruction *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira, | ... | @@ -16802,9 +16826,9 @@ static IrInstruction *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira, |
| 16802 | static TypeStructField *validate_byte_offset(IrAnalyze *ira, | 16826 | static TypeStructField *validate_byte_offset(IrAnalyze *ira, |
| 16803 | IrInstruction *type_value, | 16827 | IrInstruction *type_value, |
| 16804 | IrInstruction *field_name_value, | 16828 | IrInstruction *field_name_value, |
| 16805 | size_t *byte_offset) | 16829 | size_t *byte_offset) |
| 16806 | { | 16830 | { |
| 16807 | ZigType *container_type = ir_resolve_type(ira, type_value, ZigTypeIdStruct); | 16831 | ZigType *container_type = ir_resolve_type(ira, type_value); |
| 16808 | if (type_is_invalid(container_type)) | 16832 | if (type_is_invalid(container_type)) |
| 16809 | return nullptr; | 16833 | return nullptr; |
| 16810 | | 16834 | |
| ... | @@ -16816,6 +16840,12 @@ static TypeStructField *validate_byte_offset(IrAnalyze *ira, | ... | @@ -16816,6 +16840,12 @@ static TypeStructField *validate_byte_offset(IrAnalyze *ira, |
| 16816 | if (!field_name) | 16840 | if (!field_name) |
| 16817 | return nullptr; | 16841 | return nullptr; |
| 16818 | | 16842 | |
| | 16843 | if (container_type->id != ZigTypeIdStruct) { |
| | 16844 | ir_add_error(ira, type_value, |
| | 16845 | buf_sprintf("expected struct type, found '%s'", buf_ptr(&container_type->name))); |
| | 16846 | return nullptr; |
| | 16847 | } |
| | 16848 | |
| 16819 | TypeStructField *field = find_struct_type_field(container_type, field_name); | 16849 | TypeStructField *field = find_struct_type_field(container_type, field_name); |
| 16820 | if (field == nullptr) { | 16850 | if (field == nullptr) { |
| 16821 | ir_add_error(ira, field_name_value, | 16851 | ir_add_error(ira, field_name_value, |
| ... | @@ -17793,7 +17823,7 @@ static IrInstruction *ir_analyze_instruction_type_info(IrAnalyze *ira, | ... | @@ -17793,7 +17823,7 @@ static IrInstruction *ir_analyze_instruction_type_info(IrAnalyze *ira, |
| 17793 | { | 17823 | { |
| 17794 | Error err; | 17824 | Error err; |
| 17795 | IrInstruction *type_value = instruction->type_value->child; | 17825 | IrInstruction *type_value = instruction->type_value->child; |
| 17796 | ZigType *type_entry = ir_resolve_type(ira, type_value, ZigTypeIdInvalid); | 17826 | ZigType *type_entry = ir_resolve_type(ira, type_value); |
| 17797 | if (type_is_invalid(type_entry)) | 17827 | if (type_is_invalid(type_entry)) |
| 17798 | return ira->codegen->invalid_instruction; | 17828 | return ira->codegen->invalid_instruction; |
| 17799 | | 17829 | |
| ... | @@ -17821,7 +17851,7 @@ static IrInstruction *ir_analyze_instruction_type_id(IrAnalyze *ira, | ... | @@ -17821,7 +17851,7 @@ static IrInstruction *ir_analyze_instruction_type_id(IrAnalyze *ira, |
| 17821 | IrInstructionTypeId *instruction) | 17851 | IrInstructionTypeId *instruction) |
| 17822 | { | 17852 | { |
| 17823 | IrInstruction *type_value = instruction->type_value->child; | 17853 | IrInstruction *type_value = instruction->type_value->child; |
| 17824 | ZigType *type_entry = ir_resolve_type(ira, type_value, ZigTypeIdInvalid); | 17854 | ZigType *type_entry = ir_resolve_type(ira, type_value); |
| 17825 | if (type_is_invalid(type_entry)) | 17855 | if (type_is_invalid(type_entry)) |
| 17826 | return ira->codegen->invalid_instruction; | 17856 | return ira->codegen->invalid_instruction; |
| 17827 | | 17857 | |
| ... | @@ -17856,7 +17886,7 @@ static IrInstruction *ir_analyze_instruction_set_eval_branch_quota(IrAnalyze *ir | ... | @@ -17856,7 +17886,7 @@ static IrInstruction *ir_analyze_instruction_set_eval_branch_quota(IrAnalyze *ir |
| 17856 | | 17886 | |
| 17857 | static IrInstruction *ir_analyze_instruction_type_name(IrAnalyze *ira, IrInstructionTypeName *instruction) { | 17887 | static IrInstruction *ir_analyze_instruction_type_name(IrAnalyze *ira, IrInstructionTypeName *instruction) { |
| 17858 | IrInstruction *type_value = instruction->type_value->child; | 17888 | IrInstruction *type_value = instruction->type_value->child; |
| 17859 | ZigType *type_entry = ir_resolve_type(ira, type_value, ZigTypeIdInvalid); | 17889 | ZigType *type_entry = ir_resolve_type(ira, type_value); |
| 17860 | if (type_is_invalid(type_entry)) | 17890 | if (type_is_invalid(type_entry)) |
| 17861 | return ira->codegen->invalid_instruction; | 17891 | return ira->codegen->invalid_instruction; |
| 17862 | | 17892 | |
| ... | @@ -18133,7 +18163,7 @@ static IrInstruction *ir_analyze_instruction_fence(IrAnalyze *ira, IrInstruction | ... | @@ -18133,7 +18163,7 @@ static IrInstruction *ir_analyze_instruction_fence(IrAnalyze *ira, IrInstruction |
| 18133 | | 18163 | |
| 18134 | static IrInstruction *ir_analyze_instruction_truncate(IrAnalyze *ira, IrInstructionTruncate *instruction) { | 18164 | static IrInstruction *ir_analyze_instruction_truncate(IrAnalyze *ira, IrInstructionTruncate *instruction) { |
| 18135 | IrInstruction *dest_type_value = instruction->dest_type->child; | 18165 | IrInstruction *dest_type_value = instruction->dest_type->child; |
| 18136 | ZigType *dest_type = ir_resolve_type(ira, dest_type_value, ZigTypeIdInvalid); | 18166 | ZigType *dest_type = ir_resolve_type(ira, dest_type_value); |
| 18137 | if (type_is_invalid(dest_type)) | 18167 | if (type_is_invalid(dest_type)) |
| 18138 | return ira->codegen->invalid_instruction; | 18168 | return ira->codegen->invalid_instruction; |
| 18139 | | 18169 | |
| ... | @@ -18186,7 +18216,7 @@ static IrInstruction *ir_analyze_instruction_truncate(IrAnalyze *ira, IrInstruct | ... | @@ -18186,7 +18216,7 @@ static IrInstruction *ir_analyze_instruction_truncate(IrAnalyze *ira, IrInstruct |
| 18186 | } | 18216 | } |
| 18187 | | 18217 | |
| 18188 | static IrInstruction *ir_analyze_instruction_int_cast(IrAnalyze *ira, IrInstructionIntCast *instruction) { | 18218 | static IrInstruction *ir_analyze_instruction_int_cast(IrAnalyze *ira, IrInstructionIntCast *instruction) { |
| 18189 | ZigType *dest_type = ir_resolve_type(ira, instruction->dest_type->child, ZigTypeIdInvalid); | 18219 | ZigType *dest_type = ir_resolve_type(ira, instruction->dest_type->child); |
| 18190 | if (type_is_invalid(dest_type)) | 18220 | if (type_is_invalid(dest_type)) |
| 18191 | return ira->codegen->invalid_instruction; | 18221 | return ira->codegen->invalid_instruction; |
| 18192 | | 18222 | |
| ... | @@ -18219,7 +18249,7 @@ static IrInstruction *ir_analyze_instruction_int_cast(IrAnalyze *ira, IrInstruct | ... | @@ -18219,7 +18249,7 @@ static IrInstruction *ir_analyze_instruction_int_cast(IrAnalyze *ira, IrInstruct |
| 18219 | } | 18249 | } |
| 18220 | | 18250 | |
| 18221 | static IrInstruction *ir_analyze_instruction_float_cast(IrAnalyze *ira, IrInstructionFloatCast *instruction) { | 18251 | static IrInstruction *ir_analyze_instruction_float_cast(IrAnalyze *ira, IrInstructionFloatCast *instruction) { |
| 18222 | ZigType *dest_type = ir_resolve_type(ira, instruction->dest_type->child, ZigTypeIdInvalid); | 18252 | ZigType *dest_type = ir_resolve_type(ira, instruction->dest_type->child); |
| 18223 | if (type_is_invalid(dest_type)) | 18253 | if (type_is_invalid(dest_type)) |
| 18224 | return ira->codegen->invalid_instruction; | 18254 | return ira->codegen->invalid_instruction; |
| 18225 | | 18255 | |
| ... | @@ -18259,10 +18289,16 @@ static IrInstruction *ir_analyze_instruction_float_cast(IrAnalyze *ira, IrInstru | ... | @@ -18259,10 +18289,16 @@ static IrInstruction *ir_analyze_instruction_float_cast(IrAnalyze *ira, IrInstru |
| 18259 | } | 18289 | } |
| 18260 | | 18290 | |
| 18261 | static IrInstruction *ir_analyze_instruction_err_set_cast(IrAnalyze *ira, IrInstructionErrSetCast *instruction) { | 18291 | static IrInstruction *ir_analyze_instruction_err_set_cast(IrAnalyze *ira, IrInstructionErrSetCast *instruction) { |
| 18262 | ZigType *dest_type = ir_resolve_type(ira, instruction->dest_type->child, ZigTypeIdErrorSet); | 18292 | ZigType *dest_type = ir_resolve_type(ira, instruction->dest_type->child); |
| 18263 | if (type_is_invalid(dest_type)) | 18293 | if (type_is_invalid(dest_type)) |
| 18264 | return ira->codegen->invalid_instruction; | 18294 | return ira->codegen->invalid_instruction; |
| 18265 | | 18295 | |
| | 18296 | if (dest_type->id != ZigTypeIdErrorSet) { |
| | 18297 | ir_add_error(ira, instruction->dest_type, |
| | 18298 | buf_sprintf("expected error set type, found '%s'", buf_ptr(&dest_type->name))); |
| | 18299 | return ira->codegen->invalid_instruction; |
| | 18300 | } |
| | 18301 | |
| 18266 | IrInstruction *target = instruction->target->child; | 18302 | IrInstruction *target = instruction->target->child; |
| 18267 | if (type_is_invalid(target->value.type)) | 18303 | if (type_is_invalid(target->value.type)) |
| 18268 | return ira->codegen->invalid_instruction; | 18304 | return ira->codegen->invalid_instruction; |
| ... | @@ -18291,7 +18327,7 @@ static Error resolve_ptr_align(IrAnalyze *ira, ZigType *ty, uint32_t *result_ali | ... | @@ -18291,7 +18327,7 @@ static Error resolve_ptr_align(IrAnalyze *ira, ZigType *ty, uint32_t *result_ali |
| 18291 | static IrInstruction *ir_analyze_instruction_from_bytes(IrAnalyze *ira, IrInstructionFromBytes *instruction) { | 18327 | static IrInstruction *ir_analyze_instruction_from_bytes(IrAnalyze *ira, IrInstructionFromBytes *instruction) { |
| 18292 | Error err; | 18328 | Error err; |
| 18293 | | 18329 | |
| 18294 | ZigType *dest_child_type = ir_resolve_type(ira, instruction->dest_child_type->child, ZigTypeIdInvalid); | 18330 | ZigType *dest_child_type = ir_resolve_type(ira, instruction->dest_child_type->child); |
| 18295 | if (type_is_invalid(dest_child_type)) | 18331 | if (type_is_invalid(dest_child_type)) |
| 18296 | return ira->codegen->invalid_instruction; | 18332 | return ira->codegen->invalid_instruction; |
| 18297 | | 18333 | |
| ... | @@ -18388,7 +18424,7 @@ static IrInstruction *ir_analyze_instruction_to_bytes(IrAnalyze *ira, IrInstruct | ... | @@ -18388,7 +18424,7 @@ static IrInstruction *ir_analyze_instruction_to_bytes(IrAnalyze *ira, IrInstruct |
| 18388 | | 18424 | |
| 18389 | if (!is_slice(target->value.type)) { | 18425 | if (!is_slice(target->value.type)) { |
| 18390 | ir_add_error(ira, instruction->target, | 18426 | ir_add_error(ira, instruction->target, |
| 18391 | buf_sprintf("expected slice type, found '%s'", buf_ptr(&target->value.type->name))); | 18427 | buf_sprintf("expected slice, found '%s'", buf_ptr(&target->value.type->name))); |
| 18392 | return ira->codegen->invalid_instruction; | 18428 | return ira->codegen->invalid_instruction; |
| 18393 | } | 18429 | } |
| 18394 | | 18430 | |
| ... | @@ -18407,7 +18443,7 @@ static IrInstruction *ir_analyze_instruction_to_bytes(IrAnalyze *ira, IrInstruct | ... | @@ -18407,7 +18443,7 @@ static IrInstruction *ir_analyze_instruction_to_bytes(IrAnalyze *ira, IrInstruct |
| 18407 | } | 18443 | } |
| 18408 | | 18444 | |
| 18409 | static IrInstruction *ir_analyze_instruction_int_to_float(IrAnalyze *ira, IrInstructionIntToFloat *instruction) { | 18445 | static IrInstruction *ir_analyze_instruction_int_to_float(IrAnalyze *ira, IrInstructionIntToFloat *instruction) { |
| 18410 | ZigType *dest_type = ir_resolve_type(ira, instruction->dest_type->child, ZigTypeIdInvalid); | 18446 | ZigType *dest_type = ir_resolve_type(ira, instruction->dest_type->child); |
| 18411 | if (type_is_invalid(dest_type)) | 18447 | if (type_is_invalid(dest_type)) |
| 18412 | return ira->codegen->invalid_instruction; | 18448 | return ira->codegen->invalid_instruction; |
| 18413 | | 18449 | |
| ... | @@ -18425,7 +18461,7 @@ static IrInstruction *ir_analyze_instruction_int_to_float(IrAnalyze *ira, IrInst | ... | @@ -18425,7 +18461,7 @@ static IrInstruction *ir_analyze_instruction_int_to_float(IrAnalyze *ira, IrInst |
| 18425 | } | 18461 | } |
| 18426 | | 18462 | |
| 18427 | static IrInstruction *ir_analyze_instruction_float_to_int(IrAnalyze *ira, IrInstructionFloatToInt *instruction) { | 18463 | static IrInstruction *ir_analyze_instruction_float_to_int(IrAnalyze *ira, IrInstructionFloatToInt *instruction) { |
| 18428 | ZigType *dest_type = ir_resolve_type(ira, instruction->dest_type->child, ZigTypeIdInvalid); | 18464 | ZigType *dest_type = ir_resolve_type(ira, instruction->dest_type->child); |
| 18429 | if (type_is_invalid(dest_type)) | 18465 | if (type_is_invalid(dest_type)) |
| 18430 | return ira->codegen->invalid_instruction; | 18466 | return ira->codegen->invalid_instruction; |
| 18431 | | 18467 | |
| ... | @@ -18481,7 +18517,7 @@ static IrInstruction *ir_analyze_instruction_bool_to_int(IrAnalyze *ira, IrInstr | ... | @@ -18481,7 +18517,7 @@ static IrInstruction *ir_analyze_instruction_bool_to_int(IrAnalyze *ira, IrInstr |
| 18481 | return ira->codegen->invalid_instruction; | 18517 | return ira->codegen->invalid_instruction; |
| 18482 | | 18518 | |
| 18483 | if (target->value.type->id != ZigTypeIdBool) { | 18519 | if (target->value.type->id != ZigTypeIdBool) { |
| 18484 | ir_add_error(ira, instruction->target, buf_sprintf("expected bool type, found '%s'", | 18520 | ir_add_error(ira, instruction->target, buf_sprintf("expected bool, found '%s'", |
| 18485 | buf_ptr(&target->value.type->name))); | 18521 | buf_ptr(&target->value.type->name))); |
| 18486 | return ira->codegen->invalid_instruction; | 18522 | return ira->codegen->invalid_instruction; |
| 18487 | } | 18523 | } |
| ... | @@ -19062,7 +19098,7 @@ static IrInstruction *ir_analyze_instruction_member_count(IrAnalyze *ira, IrInst | ... | @@ -19062,7 +19098,7 @@ static IrInstruction *ir_analyze_instruction_member_count(IrAnalyze *ira, IrInst |
| 19062 | IrInstruction *container = instruction->container->child; | 19098 | IrInstruction *container = instruction->container->child; |
| 19063 | if (type_is_invalid(container->value.type)) | 19099 | if (type_is_invalid(container->value.type)) |
| 19064 | return ira->codegen->invalid_instruction; | 19100 | return ira->codegen->invalid_instruction; |
| 19065 | ZigType *container_type = ir_resolve_type(ira, container, ZigTypeIdInvalid); | 19101 | ZigType *container_type = ir_resolve_type(ira, container); |
| 19066 | | 19102 | |
| 19067 | if ((err = ensure_complete_type(ira->codegen, container_type))) | 19103 | if ((err = ensure_complete_type(ira->codegen, container_type))) |
| 19068 | return ira->codegen->invalid_instruction; | 19104 | return ira->codegen->invalid_instruction; |
| ... | @@ -19096,7 +19132,7 @@ static IrInstruction *ir_analyze_instruction_member_count(IrAnalyze *ira, IrInst | ... | @@ -19096,7 +19132,7 @@ static IrInstruction *ir_analyze_instruction_member_count(IrAnalyze *ira, IrInst |
| 19096 | static IrInstruction *ir_analyze_instruction_member_type(IrAnalyze *ira, IrInstructionMemberType *instruction) { | 19132 | static IrInstruction *ir_analyze_instruction_member_type(IrAnalyze *ira, IrInstructionMemberType *instruction) { |
| 19097 | Error err; | 19133 | Error err; |
| 19098 | IrInstruction *container_type_value = instruction->container_type->child; | 19134 | IrInstruction *container_type_value = instruction->container_type->child; |
| 19099 | ZigType *container_type = ir_resolve_type(ira, container_type_value, ZigTypeIdInvalid); | 19135 | ZigType *container_type = ir_resolve_type(ira, container_type_value); |
| 19100 | if (type_is_invalid(container_type)) | 19136 | if (type_is_invalid(container_type)) |
| 19101 | return ira->codegen->invalid_instruction; | 19137 | return ira->codegen->invalid_instruction; |
| 19102 | | 19138 | |
| ... | @@ -19139,7 +19175,7 @@ static IrInstruction *ir_analyze_instruction_member_type(IrAnalyze *ira, IrInstr | ... | @@ -19139,7 +19175,7 @@ static IrInstruction *ir_analyze_instruction_member_type(IrAnalyze *ira, IrInstr |
| 19139 | static IrInstruction *ir_analyze_instruction_member_name(IrAnalyze *ira, IrInstructionMemberName *instruction) { | 19175 | static IrInstruction *ir_analyze_instruction_member_name(IrAnalyze *ira, IrInstructionMemberName *instruction) { |
| 19140 | Error err; | 19176 | Error err; |
| 19141 | IrInstruction *container_type_value = instruction->container_type->child; | 19177 | IrInstruction *container_type_value = instruction->container_type->child; |
| 19142 | ZigType *container_type = ir_resolve_type(ira, container_type_value, ZigTypeIdInvalid); | 19178 | ZigType *container_type = ir_resolve_type(ira, container_type_value); |
| 19143 | if (type_is_invalid(container_type)) | 19179 | if (type_is_invalid(container_type)) |
| 19144 | return ira->codegen->invalid_instruction; | 19180 | return ira->codegen->invalid_instruction; |
| 19145 | | 19181 | |
| ... | @@ -19232,7 +19268,7 @@ static IrInstruction *ir_analyze_instruction_align_of(IrAnalyze *ira, IrInstruct | ... | @@ -19232,7 +19268,7 @@ static IrInstruction *ir_analyze_instruction_align_of(IrAnalyze *ira, IrInstruct |
| 19232 | IrInstruction *type_value = instruction->type_value->child; | 19268 | IrInstruction *type_value = instruction->type_value->child; |
| 19233 | if (type_is_invalid(type_value->value.type)) | 19269 | if (type_is_invalid(type_value->value.type)) |
| 19234 | return ira->codegen->invalid_instruction; | 19270 | return ira->codegen->invalid_instruction; |
| 19235 | ZigType *type_entry = ir_resolve_type(ira, type_value, ZigTypeIdInvalid); | 19271 | ZigType *type_entry = ir_resolve_type(ira, type_value); |
| 19236 | | 19272 | |
| 19237 | if ((err = type_resolve(ira->codegen, type_entry, ResolveStatusAlignmentKnown))) | 19273 | if ((err = type_resolve(ira->codegen, type_entry, ResolveStatusAlignmentKnown))) |
| 19238 | return ira->codegen->invalid_instruction; | 19274 | return ira->codegen->invalid_instruction; |
| ... | @@ -19282,10 +19318,16 @@ static IrInstruction *ir_analyze_instruction_overflow_op(IrAnalyze *ira, IrInstr | ... | @@ -19282,10 +19318,16 @@ static IrInstruction *ir_analyze_instruction_overflow_op(IrAnalyze *ira, IrInstr |
| 19282 | if (type_is_invalid(type_value->value.type)) | 19318 | if (type_is_invalid(type_value->value.type)) |
| 19283 | return ira->codegen->invalid_instruction; | 19319 | return ira->codegen->invalid_instruction; |
| 19284 | | 19320 | |
| 19285 | ZigType *dest_type = ir_resolve_type(ira, type_value, ZigTypeIdInt); | 19321 | ZigType *dest_type = ir_resolve_type(ira, type_value); |
| 19286 | if (type_is_invalid(dest_type)) | 19322 | if (type_is_invalid(dest_type)) |
| 19287 | return ira->codegen->invalid_instruction; | 19323 | return ira->codegen->invalid_instruction; |
| 19288 | | 19324 | |
| | 19325 | if (dest_type->id != ZigTypeIdInt) { |
| | 19326 | ir_add_error(ira, type_value, |
| | 19327 | buf_sprintf("expected integer type, found '%s'", buf_ptr(&dest_type->name))); |
| | 19328 | return ira->codegen->invalid_instruction; |
| | 19329 | } |
| | 19330 | |
| 19289 | IrInstruction *op1 = instruction->op1->child; | 19331 | IrInstruction *op1 = instruction->op1->child; |
| 19290 | if (type_is_invalid(op1->value.type)) | 19332 | if (type_is_invalid(op1->value.type)) |
| 19291 | return ira->codegen->invalid_instruction; | 19333 | return ira->codegen->invalid_instruction; |
| ... | @@ -19555,7 +19597,7 @@ static IrInstruction *ir_analyze_instruction_fn_proto(IrAnalyze *ira, IrInstruct | ... | @@ -19555,7 +19597,7 @@ static IrInstruction *ir_analyze_instruction_fn_proto(IrAnalyze *ira, IrInstruct |
| 19555 | IrInstruction *param_type_value = instruction->param_types[fn_type_id.next_param_index]->child; | 19597 | IrInstruction *param_type_value = instruction->param_types[fn_type_id.next_param_index]->child; |
| 19556 | if (type_is_invalid(param_type_value->value.type)) | 19598 | if (type_is_invalid(param_type_value->value.type)) |
| 19557 | return ira->codegen->invalid_instruction; | 19599 | return ira->codegen->invalid_instruction; |
| 19558 | ZigType *param_type = ir_resolve_type(ira, param_type_value, ZigTypeIdInvalid); | 19600 | ZigType *param_type = ir_resolve_type(ira, param_type_value); |
| 19559 | switch (type_requires_comptime(ira->codegen, param_type)) { | 19601 | switch (type_requires_comptime(ira->codegen, param_type)) { |
| 19560 | case ReqCompTimeYes: | 19602 | case ReqCompTimeYes: |
| 19561 | if (!calling_convention_allows_zig_types(fn_type_id.cc)) { | 19603 | if (!calling_convention_allows_zig_types(fn_type_id.cc)) { |
| ... | @@ -19589,7 +19631,7 @@ static IrInstruction *ir_analyze_instruction_fn_proto(IrAnalyze *ira, IrInstruct | ... | @@ -19589,7 +19631,7 @@ static IrInstruction *ir_analyze_instruction_fn_proto(IrAnalyze *ira, IrInstruct |
| 19589 | } | 19631 | } |
| 19590 | | 19632 | |
| 19591 | IrInstruction *return_type_value = instruction->return_type->child; | 19633 | IrInstruction *return_type_value = instruction->return_type->child; |
| 19592 | fn_type_id.return_type = ir_resolve_type(ira, return_type_value, ZigTypeIdInvalid); | 19634 | fn_type_id.return_type = ir_resolve_type(ira, return_type_value); |
| 19593 | if (type_is_invalid(fn_type_id.return_type)) | 19635 | if (type_is_invalid(fn_type_id.return_type)) |
| 19594 | return ira->codegen->invalid_instruction; | 19636 | return ira->codegen->invalid_instruction; |
| 19595 | if (fn_type_id.return_type->id == ZigTypeIdOpaque) { | 19637 | if (fn_type_id.return_type->id == ZigTypeIdOpaque) { |
| ... | @@ -19605,7 +19647,7 @@ static IrInstruction *ir_analyze_instruction_fn_proto(IrAnalyze *ira, IrInstruct | ... | @@ -19605,7 +19647,7 @@ static IrInstruction *ir_analyze_instruction_fn_proto(IrAnalyze *ira, IrInstruct |
| 19605 | return ira->codegen->invalid_instruction; | 19647 | return ira->codegen->invalid_instruction; |
| 19606 | } | 19648 | } |
| 19607 | IrInstruction *async_allocator_type_value = instruction->async_allocator_type_value->child; | 19649 | IrInstruction *async_allocator_type_value = instruction->async_allocator_type_value->child; |
| 19608 | fn_type_id.async_allocator_type = ir_resolve_type(ira, async_allocator_type_value, ZigTypeIdInvalid); | 19650 | fn_type_id.async_allocator_type = ir_resolve_type(ira, async_allocator_type_value); |
| 19609 | if (type_is_invalid(fn_type_id.async_allocator_type)) | 19651 | if (type_is_invalid(fn_type_id.async_allocator_type)) |
| 19610 | return ira->codegen->invalid_instruction; | 19652 | return ira->codegen->invalid_instruction; |
| 19611 | } | 19653 | } |
| ... | @@ -19913,7 +19955,7 @@ static IrInstruction *ir_align_cast(IrAnalyze *ira, IrInstruction *target, uint3 | ... | @@ -19913,7 +19955,7 @@ static IrInstruction *ir_align_cast(IrAnalyze *ira, IrInstruction *target, uint3 |
| 19913 | result_type = get_slice_type(ira->codegen, result_ptr_type); | 19955 | result_type = get_slice_type(ira->codegen, result_ptr_type); |
| 19914 | } else { | 19956 | } else { |
| 19915 | ir_add_error(ira, target, | 19957 | ir_add_error(ira, target, |
| 19916 | buf_sprintf("expected pointer or slice type, found '%s'", buf_ptr(&target_type->name))); | 19958 | buf_sprintf("expected pointer or slice, found '%s'", buf_ptr(&target_type->name))); |
| 19917 | return ira->codegen->invalid_instruction; | 19959 | return ira->codegen->invalid_instruction; |
| 19918 | } | 19960 | } |
| 19919 | | 19961 | |
| ... | @@ -19959,13 +20001,13 @@ static IrInstruction *ir_analyze_ptr_cast(IrAnalyze *ira, IrInstruction *source_ | ... | @@ -19959,13 +20001,13 @@ static IrInstruction *ir_analyze_ptr_cast(IrAnalyze *ira, IrInstruction *source_ |
| 19959 | // validate src_type and dest_type. | 20001 | // validate src_type and dest_type. |
| 19960 | | 20002 | |
| 19961 | if (get_src_ptr_type(src_type) == nullptr) { | 20003 | if (get_src_ptr_type(src_type) == nullptr) { |
| 19962 | ir_add_error(ira, ptr, buf_sprintf("expected Pointer type, found '%s'", buf_ptr(&src_type->name))); | 20004 | ir_add_error(ira, ptr, buf_sprintf("expected pointer, found '%s'", buf_ptr(&src_type->name))); |
| 19963 | return ira->codegen->invalid_instruction; | 20005 | return ira->codegen->invalid_instruction; |
| 19964 | } | 20006 | } |
| 19965 | | 20007 | |
| 19966 | if (get_src_ptr_type(dest_type) == nullptr) { | 20008 | if (get_src_ptr_type(dest_type) == nullptr) { |
| 19967 | ir_add_error(ira, dest_type_src, | 20009 | ir_add_error(ira, dest_type_src, |
| 19968 | buf_sprintf("expected Pointer type, found '%s'", buf_ptr(&dest_type->name))); | 20010 | buf_sprintf("expected pointer, found '%s'", buf_ptr(&dest_type->name))); |
| 19969 | return ira->codegen->invalid_instruction; | 20011 | return ira->codegen->invalid_instruction; |
| 19970 | } | 20012 | } |
| 19971 | | 20013 | |
| ... | @@ -20033,7 +20075,7 @@ static IrInstruction *ir_analyze_ptr_cast(IrAnalyze *ira, IrInstruction *source_ | ... | @@ -20033,7 +20075,7 @@ static IrInstruction *ir_analyze_ptr_cast(IrAnalyze *ira, IrInstruction *source_ |
| 20033 | | 20075 | |
| 20034 | static IrInstruction *ir_analyze_instruction_ptr_cast(IrAnalyze *ira, IrInstructionPtrCast *instruction) { | 20076 | static IrInstruction *ir_analyze_instruction_ptr_cast(IrAnalyze *ira, IrInstructionPtrCast *instruction) { |
| 20035 | IrInstruction *dest_type_value = instruction->dest_type->child; | 20077 | IrInstruction *dest_type_value = instruction->dest_type->child; |
| 20036 | ZigType *dest_type = ir_resolve_type(ira, dest_type_value, ZigTypeIdInvalid); | 20078 | ZigType *dest_type = ir_resolve_type(ira, dest_type_value); |
| 20037 | if (type_is_invalid(dest_type)) | 20079 | if (type_is_invalid(dest_type)) |
| 20038 | return ira->codegen->invalid_instruction; | 20080 | return ira->codegen->invalid_instruction; |
| 20039 | | 20081 | |
| ... | @@ -20229,7 +20271,7 @@ static Error buf_read_value_bytes(IrAnalyze *ira, CodeGen *codegen, AstNode *sou | ... | @@ -20229,7 +20271,7 @@ static Error buf_read_value_bytes(IrAnalyze *ira, CodeGen *codegen, AstNode *sou |
| 20229 | static IrInstruction *ir_analyze_instruction_bit_cast(IrAnalyze *ira, IrInstructionBitCast *instruction) { | 20271 | static IrInstruction *ir_analyze_instruction_bit_cast(IrAnalyze *ira, IrInstructionBitCast *instruction) { |
| 20230 | Error err; | 20272 | Error err; |
| 20231 | IrInstruction *dest_type_value = instruction->dest_type->child; | 20273 | IrInstruction *dest_type_value = instruction->dest_type->child; |
| 20232 | ZigType *dest_type = ir_resolve_type(ira, dest_type_value, ZigTypeIdInvalid); | 20274 | ZigType *dest_type = ir_resolve_type(ira, dest_type_value); |
| 20233 | if (type_is_invalid(dest_type)) | 20275 | if (type_is_invalid(dest_type)) |
| 20234 | return ira->codegen->invalid_instruction; | 20276 | return ira->codegen->invalid_instruction; |
| 20235 | | 20277 | |
| ... | @@ -20326,13 +20368,13 @@ static IrInstruction *ir_analyze_instruction_bit_cast(IrAnalyze *ira, IrInstruct | ... | @@ -20326,13 +20368,13 @@ static IrInstruction *ir_analyze_instruction_bit_cast(IrAnalyze *ira, IrInstruct |
| 20326 | static IrInstruction *ir_analyze_instruction_int_to_ptr(IrAnalyze *ira, IrInstructionIntToPtr *instruction) { | 20368 | static IrInstruction *ir_analyze_instruction_int_to_ptr(IrAnalyze *ira, IrInstructionIntToPtr *instruction) { |
| 20327 | Error err; | 20369 | Error err; |
| 20328 | IrInstruction *dest_type_value = instruction->dest_type->child; | 20370 | IrInstruction *dest_type_value = instruction->dest_type->child; |
| 20329 | ZigType *dest_type = ir_resolve_type(ira, dest_type_value, ZigTypeIdInvalid); | 20371 | ZigType *dest_type = ir_resolve_type(ira, dest_type_value); |
| 20330 | if (type_is_invalid(dest_type)) | 20372 | if (type_is_invalid(dest_type)) |
| 20331 | return ira->codegen->invalid_instruction; | 20373 | return ira->codegen->invalid_instruction; |
| 20332 | | 20374 | |
| 20333 | // We explicitly check for the size, so we can use get_src_ptr_type | 20375 | // We explicitly check for the size, so we can use get_src_ptr_type |
| 20334 | if (get_src_ptr_type(dest_type) == nullptr) { | 20376 | if (get_src_ptr_type(dest_type) == nullptr) { |
| 20335 | ir_add_error(ira, dest_type_value, buf_sprintf("expected Pointer type, found '%s'", buf_ptr(&dest_type->name))); | 20377 | ir_add_error(ira, dest_type_value, buf_sprintf("expected pointer, found '%s'", buf_ptr(&dest_type->name))); |
| 20336 | return ira->codegen->invalid_instruction; | 20378 | return ira->codegen->invalid_instruction; |
| 20337 | } | 20379 | } |
| 20338 | | 20380 | |
| ... | @@ -20435,7 +20477,7 @@ static IrInstruction *ir_analyze_instruction_ptr_to_int(IrAnalyze *ira, IrInstru | ... | @@ -20435,7 +20477,7 @@ static IrInstruction *ir_analyze_instruction_ptr_to_int(IrAnalyze *ira, IrInstru |
| 20435 | // We check size explicitly so we can use get_src_ptr_type here. | 20477 | // We check size explicitly so we can use get_src_ptr_type here. |
| 20436 | if (get_src_ptr_type(target->value.type) == nullptr) { | 20478 | if (get_src_ptr_type(target->value.type) == nullptr) { |
| 20437 | ir_add_error(ira, target, | 20479 | ir_add_error(ira, target, |
| 20438 | buf_sprintf("expected Pointer type, found '%s'", buf_ptr(&target->value.type->name))); | 20480 | buf_sprintf("expected pointer, found '%s'", buf_ptr(&target->value.type->name))); |
| 20439 | return ira->codegen->invalid_instruction; | 20481 | return ira->codegen->invalid_instruction; |
| 20440 | } | 20482 | } |
| 20441 | | 20483 | |
| ... | @@ -20466,7 +20508,7 @@ static IrInstruction *ir_analyze_instruction_ptr_to_int(IrAnalyze *ira, IrInstru | ... | @@ -20466,7 +20508,7 @@ static IrInstruction *ir_analyze_instruction_ptr_to_int(IrAnalyze *ira, IrInstru |
| 20466 | | 20508 | |
| 20467 | static IrInstruction *ir_analyze_instruction_ptr_type(IrAnalyze *ira, IrInstructionPtrType *instruction) { | 20509 | static IrInstruction *ir_analyze_instruction_ptr_type(IrAnalyze *ira, IrInstructionPtrType *instruction) { |
| 20468 | Error err; | 20510 | Error err; |
| 20469 | ZigType *child_type = ir_resolve_type(ira, instruction->child_type->child, ZigTypeIdInvalid); | 20511 | ZigType *child_type = ir_resolve_type(ira, instruction->child_type->child); |
| 20470 | if (type_is_invalid(child_type)) | 20512 | if (type_is_invalid(child_type)) |
| 20471 | return ira->codegen->invalid_instruction; | 20513 | return ira->codegen->invalid_instruction; |
| 20472 | | 20514 | |
| ... | @@ -20565,7 +20607,7 @@ static IrInstruction *ir_analyze_instruction_set_align_stack(IrAnalyze *ira, IrI | ... | @@ -20565,7 +20607,7 @@ static IrInstruction *ir_analyze_instruction_set_align_stack(IrAnalyze *ira, IrI |
| 20565 | | 20607 | |
| 20566 | static IrInstruction *ir_analyze_instruction_arg_type(IrAnalyze *ira, IrInstructionArgType *instruction) { | 20608 | static IrInstruction *ir_analyze_instruction_arg_type(IrAnalyze *ira, IrInstructionArgType *instruction) { |
| 20567 | IrInstruction *fn_type_inst = instruction->fn_type->child; | 20609 | IrInstruction *fn_type_inst = instruction->fn_type->child; |
| 20568 | ZigType *fn_type = ir_resolve_type(ira, fn_type_inst, ZigTypeIdFn); | 20610 | ZigType *fn_type = ir_resolve_type(ira, fn_type_inst); |
| 20569 | if (type_is_invalid(fn_type)) | 20611 | if (type_is_invalid(fn_type)) |
| 20570 | return ira->codegen->invalid_instruction; | 20612 | return ira->codegen->invalid_instruction; |
| 20571 | | 20613 | |
| ... | @@ -20574,6 +20616,11 @@ static IrInstruction *ir_analyze_instruction_arg_type(IrAnalyze *ira, IrInstruct | ... | @@ -20574,6 +20616,11 @@ static IrInstruction *ir_analyze_instruction_arg_type(IrAnalyze *ira, IrInstruct |
| 20574 | if (!ir_resolve_usize(ira, arg_index_inst, &arg_index)) | 20616 | if (!ir_resolve_usize(ira, arg_index_inst, &arg_index)) |
| 20575 | return ira->codegen->invalid_instruction; | 20617 | return ira->codegen->invalid_instruction; |
| 20576 | | 20618 | |
| | 20619 | if (fn_type->id != ZigTypeIdFn) { |
| | 20620 | ir_add_error(ira, fn_type_inst, buf_sprintf("expected function, found '%s'", buf_ptr(&fn_type->name))); |
| | 20621 | return ira->codegen->invalid_instruction; |
| | 20622 | } |
| | 20623 | |
| 20577 | FnTypeId *fn_type_id = &fn_type->data.fn.fn_type_id; | 20624 | FnTypeId *fn_type_id = &fn_type->data.fn.fn_type_id; |
| 20578 | if (arg_index >= fn_type_id->param_count) { | 20625 | if (arg_index >= fn_type_id->param_count) { |
| 20579 | ir_add_error(ira, arg_index_inst, | 20626 | ir_add_error(ira, arg_index_inst, |
| ... | @@ -20598,7 +20645,7 @@ static IrInstruction *ir_analyze_instruction_arg_type(IrAnalyze *ira, IrInstruct | ... | @@ -20598,7 +20645,7 @@ static IrInstruction *ir_analyze_instruction_arg_type(IrAnalyze *ira, IrInstruct |
| 20598 | static IrInstruction *ir_analyze_instruction_tag_type(IrAnalyze *ira, IrInstructionTagType *instruction) { | 20645 | static IrInstruction *ir_analyze_instruction_tag_type(IrAnalyze *ira, IrInstructionTagType *instruction) { |
| 20599 | Error err; | 20646 | Error err; |
| 20600 | IrInstruction *target_inst = instruction->target->child; | 20647 | IrInstruction *target_inst = instruction->target->child; |
| 20601 | ZigType *enum_type = ir_resolve_type(ira, target_inst, ZigTypeIdInvalid); | 20648 | ZigType *enum_type = ir_resolve_type(ira, target_inst); |
| 20602 | if (type_is_invalid(enum_type)) | 20649 | if (type_is_invalid(enum_type)) |
| 20603 | return ira->codegen->invalid_instruction; | 20650 | return ira->codegen->invalid_instruction; |
| 20604 | | 20651 | |
| ... | @@ -20623,7 +20670,7 @@ static IrInstruction *ir_analyze_instruction_tag_type(IrAnalyze *ira, IrInstruct | ... | @@ -20623,7 +20670,7 @@ static IrInstruction *ir_analyze_instruction_tag_type(IrAnalyze *ira, IrInstruct |
| 20623 | return ira->codegen->invalid_instruction; | 20670 | return ira->codegen->invalid_instruction; |
| 20624 | } | 20671 | } |
| 20625 | } else { | 20672 | } else { |
| 20626 | ir_add_error(ira, target_inst, buf_sprintf("expected enum or union type, found '%s'", | 20673 | ir_add_error(ira, target_inst, buf_sprintf("expected enum or union, found '%s'", |
| 20627 | buf_ptr(&enum_type->name))); | 20674 | buf_ptr(&enum_type->name))); |
| 20628 | return ira->codegen->invalid_instruction; | 20675 | return ira->codegen->invalid_instruction; |
| 20629 | } | 20676 | } |
| ... | @@ -20777,7 +20824,7 @@ static IrInstruction *ir_analyze_instruction_coro_promise(IrAnalyze *ira, IrInst | ... | @@ -20777,7 +20824,7 @@ static IrInstruction *ir_analyze_instruction_coro_promise(IrAnalyze *ira, IrInst |
| 20777 | if (coro_handle->value.type->id != ZigTypeIdPromise || | 20824 | if (coro_handle->value.type->id != ZigTypeIdPromise || |
| 20778 | coro_handle->value.type->data.promise.result_type == nullptr) | 20825 | coro_handle->value.type->data.promise.result_type == nullptr) |
| 20779 | { | 20826 | { |
| 20780 | ir_add_error(ira, &instruction->base, buf_sprintf("expected promise->T type, found '%s'", | 20827 | ir_add_error(ira, &instruction->base, buf_sprintf("expected promise->T, found '%s'", |
| 20781 | buf_ptr(&coro_handle->value.type->name))); | 20828 | buf_ptr(&coro_handle->value.type->name))); |
| 20782 | return ira->codegen->invalid_instruction; | 20829 | return ira->codegen->invalid_instruction; |
| 20783 | } | 20830 | } |
| ... | @@ -20808,7 +20855,7 @@ static IrInstruction *ir_analyze_instruction_coro_alloc_helper(IrAnalyze *ira, I | ... | @@ -20808,7 +20855,7 @@ static IrInstruction *ir_analyze_instruction_coro_alloc_helper(IrAnalyze *ira, I |
| 20808 | } | 20855 | } |
| 20809 | | 20856 | |
| 20810 | static ZigType *ir_resolve_atomic_operand_type(IrAnalyze *ira, IrInstruction *op) { | 20857 | static ZigType *ir_resolve_atomic_operand_type(IrAnalyze *ira, IrInstruction *op) { |
| 20811 | ZigType *operand_type = ir_resolve_type(ira, op, ZigTypeIdInvalid); | 20858 | ZigType *operand_type = ir_resolve_type(ira, op); |
| 20812 | if (type_is_invalid(operand_type)) | 20859 | if (type_is_invalid(operand_type)) |
| 20813 | return ira->codegen->builtin_types.entry_invalid; | 20860 | return ira->codegen->builtin_types.entry_invalid; |
| 20814 | | 20861 | |
| ... | @@ -20938,12 +20985,12 @@ static IrInstruction *ir_analyze_instruction_atomic_load(IrAnalyze *ira, IrInstr | ... | @@ -20938,12 +20985,12 @@ static IrInstruction *ir_analyze_instruction_atomic_load(IrAnalyze *ira, IrInstr |
| 20938 | } | 20985 | } |
| 20939 | | 20986 | |
| 20940 | static IrInstruction *ir_analyze_instruction_promise_result_type(IrAnalyze *ira, IrInstructionPromiseResultType *instruction) { | 20987 | static IrInstruction *ir_analyze_instruction_promise_result_type(IrAnalyze *ira, IrInstructionPromiseResultType *instruction) { |
| 20941 | ZigType *promise_type = ir_resolve_type(ira, instruction->promise_type->child, ZigTypeIdInvalid); | 20988 | ZigType *promise_type = ir_resolve_type(ira, instruction->promise_type->child); |
| 20942 | if (type_is_invalid(promise_type)) | 20989 | if (type_is_invalid(promise_type)) |
| 20943 | return ira->codegen->invalid_instruction; | 20990 | return ira->codegen->invalid_instruction; |
| 20944 | | 20991 | |
| 20945 | if (promise_type->id != ZigTypeIdPromise || promise_type->data.promise.result_type == nullptr) { | 20992 | if (promise_type->id != ZigTypeIdPromise || promise_type->data.promise.result_type == nullptr) { |
| 20946 | ir_add_error(ira, &instruction->base, buf_sprintf("expected promise->T type, found '%s'", | 20993 | ir_add_error(ira, &instruction->base, buf_sprintf("expected promise->T, found '%s'", |
| 20947 | buf_ptr(&promise_type->name))); | 20994 | buf_ptr(&promise_type->name))); |
| 20948 | return ira->codegen->invalid_instruction; | 20995 | return ira->codegen->invalid_instruction; |
| 20949 | } | 20996 | } |
| ... | @@ -20952,7 +20999,7 @@ static IrInstruction *ir_analyze_instruction_promise_result_type(IrAnalyze *ira, | ... | @@ -20952,7 +20999,7 @@ static IrInstruction *ir_analyze_instruction_promise_result_type(IrAnalyze *ira, |
| 20952 | } | 20999 | } |
| 20953 | | 21000 | |
| 20954 | static IrInstruction *ir_analyze_instruction_await_bookkeeping(IrAnalyze *ira, IrInstructionAwaitBookkeeping *instruction) { | 21001 | static IrInstruction *ir_analyze_instruction_await_bookkeeping(IrAnalyze *ira, IrInstructionAwaitBookkeeping *instruction) { |
| 20955 | ZigType *promise_result_type = ir_resolve_type(ira, instruction->promise_result_type->child, ZigTypeIdInvalid); | 21002 | ZigType *promise_result_type = ir_resolve_type(ira, instruction->promise_result_type->child); |
| 20956 | if (type_is_invalid(promise_result_type)) | 21003 | if (type_is_invalid(promise_result_type)) |
| 20957 | return ira->codegen->invalid_instruction; | 21004 | return ira->codegen->invalid_instruction; |
| 20958 | | 21005 | |
| ... | @@ -21015,7 +21062,7 @@ static IrInstruction *ir_analyze_instruction_mark_err_ret_trace_ptr(IrAnalyze *i | ... | @@ -21015,7 +21062,7 @@ static IrInstruction *ir_analyze_instruction_mark_err_ret_trace_ptr(IrAnalyze *i |
| 21015 | } | 21062 | } |
| 21016 | | 21063 | |
| 21017 | static IrInstruction *ir_analyze_instruction_sqrt(IrAnalyze *ira, IrInstructionSqrt *instruction) { | 21064 | static IrInstruction *ir_analyze_instruction_sqrt(IrAnalyze *ira, IrInstructionSqrt *instruction) { |
| 21018 | ZigType *float_type = ir_resolve_type(ira, instruction->type->child, ZigTypeIdInvalid); | 21065 | ZigType *float_type = ir_resolve_type(ira, instruction->type->child); |
| 21019 | if (type_is_invalid(float_type)) | 21066 | if (type_is_invalid(float_type)) |
| 21020 | return ira->codegen->invalid_instruction; | 21067 | return ira->codegen->invalid_instruction; |
| 21021 | | 21068 | |
| ... | @@ -21082,7 +21129,7 @@ static IrInstruction *ir_analyze_instruction_sqrt(IrAnalyze *ira, IrInstructionS | ... | @@ -21082,7 +21129,7 @@ static IrInstruction *ir_analyze_instruction_sqrt(IrAnalyze *ira, IrInstructionS |
| 21082 | } | 21129 | } |
| 21083 | | 21130 | |
| 21084 | static IrInstruction *ir_analyze_instruction_bswap(IrAnalyze *ira, IrInstructionBswap *instruction) { | 21131 | static IrInstruction *ir_analyze_instruction_bswap(IrAnalyze *ira, IrInstructionBswap *instruction) { |
| 21085 | ZigType *int_type = ir_resolve_type(ira, instruction->type->child, ZigTypeIdInvalid); | 21132 | ZigType *int_type = ir_resolve_type(ira, instruction->type->child); |
| 21086 | if (type_is_invalid(int_type)) | 21133 | if (type_is_invalid(int_type)) |
| 21087 | return ira->codegen->invalid_instruction; | 21134 | return ira->codegen->invalid_instruction; |
| 21088 | | 21135 | |
| ... | @@ -21138,7 +21185,7 @@ static IrInstruction *ir_analyze_instruction_bswap(IrAnalyze *ira, IrInstruction | ... | @@ -21138,7 +21185,7 @@ static IrInstruction *ir_analyze_instruction_bswap(IrAnalyze *ira, IrInstruction |
| 21138 | } | 21185 | } |
| 21139 | | 21186 | |
| 21140 | static IrInstruction *ir_analyze_instruction_bit_reverse(IrAnalyze *ira, IrInstructionBitReverse *instruction) { | 21187 | static IrInstruction *ir_analyze_instruction_bit_reverse(IrAnalyze *ira, IrInstructionBitReverse *instruction) { |
| 21141 | ZigType *int_type = ir_resolve_type(ira, instruction->type->child, ZigTypeIdInvalid); | 21188 | ZigType *int_type = ir_resolve_type(ira, instruction->type->child); |
| 21142 | if (type_is_invalid(int_type)) | 21189 | if (type_is_invalid(int_type)) |
| 21143 | return ira->codegen->invalid_instruction; | 21190 | return ira->codegen->invalid_instruction; |
| 21144 | | 21191 | |
| ... | @@ -21209,7 +21256,7 @@ static IrInstruction *ir_analyze_instruction_enum_to_int(IrAnalyze *ira, IrInstr | ... | @@ -21209,7 +21256,7 @@ static IrInstruction *ir_analyze_instruction_enum_to_int(IrAnalyze *ira, IrInstr |
| 21209 | | 21256 | |
| 21210 | if (target->value.type->id != ZigTypeIdEnum) { | 21257 | if (target->value.type->id != ZigTypeIdEnum) { |
| 21211 | ir_add_error(ira, instruction->target, | 21258 | ir_add_error(ira, instruction->target, |
| 21212 | buf_sprintf("expected enum type, found '%s'", buf_ptr(&target->value.type->name))); | 21259 | buf_sprintf("expected enum, found type '%s'", buf_ptr(&target->value.type->name))); |
| 21213 | return ira->codegen->invalid_instruction; | 21260 | return ira->codegen->invalid_instruction; |
| 21214 | } | 21261 | } |
| 21215 | | 21262 | |
| ... | @@ -21224,10 +21271,16 @@ static IrInstruction *ir_analyze_instruction_enum_to_int(IrAnalyze *ira, IrInstr | ... | @@ -21224,10 +21271,16 @@ static IrInstruction *ir_analyze_instruction_enum_to_int(IrAnalyze *ira, IrInstr |
| 21224 | static IrInstruction *ir_analyze_instruction_int_to_enum(IrAnalyze *ira, IrInstructionIntToEnum *instruction) { | 21271 | static IrInstruction *ir_analyze_instruction_int_to_enum(IrAnalyze *ira, IrInstructionIntToEnum *instruction) { |
| 21225 | Error err; | 21272 | Error err; |
| 21226 | IrInstruction *dest_type_value = instruction->dest_type->child; | 21273 | IrInstruction *dest_type_value = instruction->dest_type->child; |
| 21227 | ZigType *dest_type = ir_resolve_type(ira, dest_type_value, ZigTypeIdEnum); | 21274 | ZigType *dest_type = ir_resolve_type(ira, dest_type_value); |
| 21228 | if (type_is_invalid(dest_type)) | 21275 | if (type_is_invalid(dest_type)) |
| 21229 | return ira->codegen->invalid_instruction; | 21276 | return ira->codegen->invalid_instruction; |
| 21230 | | 21277 | |
| | 21278 | if (dest_type->id != ZigTypeIdEnum) { |
| | 21279 | ir_add_error(ira, instruction->dest_type, |
| | 21280 | buf_sprintf("expected enum, found type '%s'", buf_ptr(&dest_type->name))); |
| | 21281 | return ira->codegen->invalid_instruction; |
| | 21282 | } |
| | 21283 | |
| 21231 | if ((err = type_resolve(ira->codegen, dest_type, ResolveStatusZeroBitsKnown))) | 21284 | if ((err = type_resolve(ira->codegen, dest_type, ResolveStatusZeroBitsKnown))) |
| 21232 | return ira->codegen->invalid_instruction; | 21285 | return ira->codegen->invalid_instruction; |
| 21233 | | 21286 | |