| ... | ... | @@ -5705,7 +5705,7 @@ static bool ir_emit_global_runtime_side_effect(IrAnalyze *ira, IrInstruction *so |
| 5705 | 5705 | static bool ir_num_lit_fits_in_other_type(IrAnalyze *ira, IrInstruction *instruction, TypeTableEntry *other_type) { |
| 5706 | 5706 | TypeTableEntry *other_type_underlying = get_underlying_type(other_type); |
| 5707 | 5707 | |
| 5708 | | if (other_type_underlying->id == TypeTableEntryIdInvalid) { |
| 5708 | if (type_is_invalid(other_type_underlying)) { |
| 5709 | 5709 | return false; |
| 5710 | 5710 | } |
| 5711 | 5711 | |
| ... | ... | @@ -5865,7 +5865,7 @@ static ImplicitCastMatchResult ir_types_match_with_implicit_cast(IrAnalyze *ira, |
| 5865 | 5865 | static TypeTableEntry *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, IrInstruction **instructions, size_t instruction_count) { |
| 5866 | 5866 | assert(instruction_count >= 1); |
| 5867 | 5867 | IrInstruction *prev_inst = instructions[0]; |
| 5868 | | if (prev_inst->value.type->id == TypeTableEntryIdInvalid) { |
| 5868 | if (type_is_invalid(prev_inst->value.type)) { |
| 5869 | 5869 | return ira->codegen->builtin_types.entry_invalid; |
| 5870 | 5870 | } |
| 5871 | 5871 | bool any_are_pure_error = (prev_inst->value.type->id == TypeTableEntryIdPureError); |
| ... | ... | @@ -5874,7 +5874,7 @@ static TypeTableEntry *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_nod |
| 5874 | 5874 | IrInstruction *cur_inst = instructions[i]; |
| 5875 | 5875 | TypeTableEntry *cur_type = cur_inst->value.type; |
| 5876 | 5876 | TypeTableEntry *prev_type = prev_inst->value.type; |
| 5877 | | if (cur_type->id == TypeTableEntryIdInvalid) { |
| 5877 | if (type_is_invalid(cur_type)) { |
| 5878 | 5878 | return cur_type; |
| 5879 | 5879 | } else if (prev_type->id == TypeTableEntryIdUnreachable) { |
| 5880 | 5880 | prev_inst = cur_inst; |
| ... | ... | @@ -6317,7 +6317,7 @@ IrInstruction *ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *node |
| 6317 | 6317 | analyzed_executable.backward_branch_quota = backward_branch_quota; |
| 6318 | 6318 | analyzed_executable.begin_scope = scope; |
| 6319 | 6319 | TypeTableEntry *result_type = ir_analyze(codegen, &ir_executable, &analyzed_executable, expected_type, node); |
| 6320 | | if (result_type->id == TypeTableEntryIdInvalid) |
| 6320 | if (type_is_invalid(result_type)) |
| 6321 | 6321 | return codegen->invalid_instruction; |
| 6322 | 6322 | |
| 6323 | 6323 | if (codegen->verbose) { |
| ... | ... | @@ -6330,7 +6330,7 @@ IrInstruction *ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *node |
| 6330 | 6330 | } |
| 6331 | 6331 | |
| 6332 | 6332 | static TypeTableEntry *ir_resolve_type(IrAnalyze *ira, IrInstruction *type_value) { |
| 6333 | | if (type_value->value.type->id == TypeTableEntryIdInvalid) |
| 6333 | if (type_is_invalid(type_value->value.type)) |
| 6334 | 6334 | return ira->codegen->builtin_types.entry_invalid; |
| 6335 | 6335 | |
| 6336 | 6336 | if (type_value->value.type->id != TypeTableEntryIdMetaType) { |
| ... | ... | @@ -6350,7 +6350,7 @@ static FnTableEntry *ir_resolve_fn(IrAnalyze *ira, IrInstruction *fn_value) { |
| 6350 | 6350 | if (fn_value == ira->codegen->invalid_instruction) |
| 6351 | 6351 | return nullptr; |
| 6352 | 6352 | |
| 6353 | | if (fn_value->value.type->id == TypeTableEntryIdInvalid) |
| 6353 | if (type_is_invalid(fn_value->value.type)) |
| 6354 | 6354 | return nullptr; |
| 6355 | 6355 | |
| 6356 | 6356 | if (fn_value->value.type->id != TypeTableEntryIdFn) { |
| ... | ... | @@ -6372,7 +6372,7 @@ static IrInstruction *ir_analyze_maybe_wrap(IrAnalyze *ira, IrInstruction *sourc |
| 6372 | 6372 | if (instr_is_comptime(value)) { |
| 6373 | 6373 | TypeTableEntry *payload_type = wanted_type->data.maybe.child_type; |
| 6374 | 6374 | IrInstruction *casted_payload = ir_implicit_cast(ira, value, payload_type); |
| 6375 | | if (casted_payload->value.type->id == TypeTableEntryIdInvalid) |
| 6375 | if (type_is_invalid(casted_payload->value.type)) |
| 6376 | 6376 | return ira->codegen->invalid_instruction; |
| 6377 | 6377 | |
| 6378 | 6378 | ConstExprValue *val = ir_resolve_const(ira, casted_payload, UndefBad); |
| ... | ... | @@ -6430,7 +6430,7 @@ static IrInstruction *ir_analyze_err_wrap_payload(IrAnalyze *ira, IrInstruction |
| 6430 | 6430 | if (instr_is_comptime(value)) { |
| 6431 | 6431 | TypeTableEntry *payload_type = wanted_type->data.error.child_type; |
| 6432 | 6432 | IrInstruction *casted_payload = ir_implicit_cast(ira, value, payload_type); |
| 6433 | | if (casted_payload->value.type->id == TypeTableEntryIdInvalid) |
| 6433 | if (type_is_invalid(casted_payload->value.type)) |
| 6434 | 6434 | return ira->codegen->invalid_instruction; |
| 6435 | 6435 | |
| 6436 | 6436 | ConstExprValue *val = ir_resolve_const(ira, casted_payload, UndefBad); |
| ... | ... | @@ -6529,7 +6529,7 @@ static IrInstruction *ir_analyze_null_to_maybe(IrAnalyze *ira, IrInstruction *so |
| 6529 | 6529 | static IrInstruction *ir_get_ref(IrAnalyze *ira, IrInstruction *source_instruction, IrInstruction *value, |
| 6530 | 6530 | bool is_const, bool is_volatile) |
| 6531 | 6531 | { |
| 6532 | | if (value->value.type->id == TypeTableEntryIdInvalid) |
| 6532 | if (type_is_invalid(value->value.type)) |
| 6533 | 6533 | return ira->codegen->invalid_instruction; |
| 6534 | 6534 | |
| 6535 | 6535 | if (value->id == IrInstructionIdLoadPtr) { |
| ... | ... | @@ -6752,9 +6752,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 6752 | 6752 | TypeTableEntry *isize_type = ira->codegen->builtin_types.entry_isize; |
| 6753 | 6753 | TypeTableEntry *usize_type = ira->codegen->builtin_types.entry_usize; |
| 6754 | 6754 | |
| 6755 | | if (wanted_type_canon->id == TypeTableEntryIdInvalid || |
| 6756 | | actual_type_canon->id == TypeTableEntryIdInvalid) |
| 6757 | | { |
| 6755 | if (type_is_invalid(wanted_type_canon) || type_is_invalid(actual_type_canon)) { |
| 6758 | 6756 | return ira->codegen->invalid_instruction; |
| 6759 | 6757 | } |
| 6760 | 6758 | |
| ... | ... | @@ -7016,9 +7014,9 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 7016 | 7014 | static IrInstruction *ir_implicit_cast(IrAnalyze *ira, IrInstruction *value, TypeTableEntry *expected_type) { |
| 7017 | 7015 | assert(value); |
| 7018 | 7016 | assert(value != ira->codegen->invalid_instruction); |
| 7019 | | assert(!expected_type || expected_type->id != TypeTableEntryIdInvalid); |
| 7017 | assert(!expected_type || !type_is_invalid(expected_type)); |
| 7020 | 7018 | assert(value->value.type); |
| 7021 | | assert(value->value.type->id != TypeTableEntryIdInvalid); |
| 7019 | assert(!type_is_invalid(value->value.type)); |
| 7022 | 7020 | if (expected_type == nullptr) |
| 7023 | 7021 | return value; // anything will do |
| 7024 | 7022 | if (expected_type == value->value.type) |
| ... | ... | @@ -7046,7 +7044,7 @@ static IrInstruction *ir_implicit_cast(IrAnalyze *ira, IrInstruction *value, Typ |
| 7046 | 7044 | |
| 7047 | 7045 | static IrInstruction *ir_get_deref(IrAnalyze *ira, IrInstruction *source_instruction, IrInstruction *ptr) { |
| 7048 | 7046 | TypeTableEntry *type_entry = ptr->value.type; |
| 7049 | | if (type_entry->id == TypeTableEntryIdInvalid) { |
| 7047 | if (type_is_invalid(type_entry)) { |
| 7050 | 7048 | return ira->codegen->invalid_instruction; |
| 7051 | 7049 | } else if (type_entry->id == TypeTableEntryIdPointer) { |
| 7052 | 7050 | TypeTableEntry *child_type = type_entry->data.pointer.child_type; |
| ... | ... | @@ -7100,11 +7098,11 @@ static TypeTableEntry *ir_analyze_ref(IrAnalyze *ira, IrInstruction *source_inst |
| 7100 | 7098 | } |
| 7101 | 7099 | |
| 7102 | 7100 | static bool ir_resolve_usize(IrAnalyze *ira, IrInstruction *value, uint64_t *out) { |
| 7103 | | if (value->value.type->id == TypeTableEntryIdInvalid) |
| 7101 | if (type_is_invalid(value->value.type)) |
| 7104 | 7102 | return false; |
| 7105 | 7103 | |
| 7106 | 7104 | IrInstruction *casted_value = ir_implicit_cast(ira, value, ira->codegen->builtin_types.entry_usize); |
| 7107 | | if (casted_value->value.type->id == TypeTableEntryIdInvalid) |
| 7105 | if (type_is_invalid(casted_value->value.type)) |
| 7108 | 7106 | return false; |
| 7109 | 7107 | |
| 7110 | 7108 | ConstExprValue *const_val = ir_resolve_const(ira, casted_value, UndefBad); |
| ... | ... | @@ -7116,11 +7114,11 @@ static bool ir_resolve_usize(IrAnalyze *ira, IrInstruction *value, uint64_t *out |
| 7116 | 7114 | } |
| 7117 | 7115 | |
| 7118 | 7116 | static bool ir_resolve_bool(IrAnalyze *ira, IrInstruction *value, bool *out) { |
| 7119 | | if (value->value.type->id == TypeTableEntryIdInvalid) |
| 7117 | if (type_is_invalid(value->value.type)) |
| 7120 | 7118 | return false; |
| 7121 | 7119 | |
| 7122 | 7120 | IrInstruction *casted_value = ir_implicit_cast(ira, value, ira->codegen->builtin_types.entry_bool); |
| 7123 | | if (casted_value->value.type->id == TypeTableEntryIdInvalid) |
| 7121 | if (type_is_invalid(casted_value->value.type)) |
| 7124 | 7122 | return false; |
| 7125 | 7123 | |
| 7126 | 7124 | ConstExprValue *const_val = ir_resolve_const(ira, casted_value, UndefBad); |
| ... | ... | @@ -7140,11 +7138,11 @@ static bool ir_resolve_comptime(IrAnalyze *ira, IrInstruction *value, bool *out) |
| 7140 | 7138 | } |
| 7141 | 7139 | |
| 7142 | 7140 | static bool ir_resolve_atomic_order(IrAnalyze *ira, IrInstruction *value, AtomicOrder *out) { |
| 7143 | | if (value->value.type->id == TypeTableEntryIdInvalid) |
| 7141 | if (type_is_invalid(value->value.type)) |
| 7144 | 7142 | return false; |
| 7145 | 7143 | |
| 7146 | 7144 | IrInstruction *casted_value = ir_implicit_cast(ira, value, ira->codegen->builtin_types.entry_atomic_order_enum); |
| 7147 | | if (casted_value->value.type->id == TypeTableEntryIdInvalid) |
| 7145 | if (type_is_invalid(casted_value->value.type)) |
| 7148 | 7146 | return false; |
| 7149 | 7147 | |
| 7150 | 7148 | ConstExprValue *const_val = ir_resolve_const(ira, casted_value, UndefBad); |
| ... | ... | @@ -7156,12 +7154,12 @@ static bool ir_resolve_atomic_order(IrAnalyze *ira, IrInstruction *value, Atomic |
| 7156 | 7154 | } |
| 7157 | 7155 | |
| 7158 | 7156 | static Buf *ir_resolve_str(IrAnalyze *ira, IrInstruction *value) { |
| 7159 | | if (value->value.type->id == TypeTableEntryIdInvalid) |
| 7157 | if (type_is_invalid(value->value.type)) |
| 7160 | 7158 | return nullptr; |
| 7161 | 7159 | |
| 7162 | 7160 | TypeTableEntry *str_type = get_slice_type(ira->codegen, ira->codegen->builtin_types.entry_u8, true); |
| 7163 | 7161 | IrInstruction *casted_value = ir_implicit_cast(ira, value, str_type); |
| 7164 | | if (casted_value->value.type->id == TypeTableEntryIdInvalid) |
| 7162 | if (type_is_invalid(casted_value->value.type)) |
| 7165 | 7163 | return nullptr; |
| 7166 | 7164 | |
| 7167 | 7165 | ConstExprValue *const_val = ir_resolve_const(ira, casted_value, UndefBad); |
| ... | ... | @@ -7191,7 +7189,7 @@ static TypeTableEntry *ir_analyze_instruction_return(IrAnalyze *ira, |
| 7191 | 7189 | IrInstructionReturn *return_instruction) |
| 7192 | 7190 | { |
| 7193 | 7191 | IrInstruction *value = return_instruction->value->other; |
| 7194 | | if (value->value.type->id == TypeTableEntryIdInvalid) |
| 7192 | if (type_is_invalid(value->value.type)) |
| 7195 | 7193 | return ir_unreach_error(ira); |
| 7196 | 7194 | ira->implicit_return_type_list.append(value); |
| 7197 | 7195 | |
| ... | ... | @@ -7211,11 +7209,11 @@ static TypeTableEntry *ir_analyze_instruction_const(IrAnalyze *ira, IrInstructio |
| 7211 | 7209 | |
| 7212 | 7210 | static TypeTableEntry *ir_analyze_bin_op_bool(IrAnalyze *ira, IrInstructionBinOp *bin_op_instruction) { |
| 7213 | 7211 | IrInstruction *op1 = bin_op_instruction->op1->other; |
| 7214 | | if (op1->value.type->id == TypeTableEntryIdInvalid) |
| 7212 | if (type_is_invalid(op1->value.type)) |
| 7215 | 7213 | return ira->codegen->builtin_types.entry_invalid; |
| 7216 | 7214 | |
| 7217 | 7215 | IrInstruction *op2 = bin_op_instruction->op2->other; |
| 7218 | | if (op2->value.type->id == TypeTableEntryIdInvalid) |
| 7216 | if (type_is_invalid(op2->value.type)) |
| 7219 | 7217 | return ira->codegen->builtin_types.entry_invalid; |
| 7220 | 7218 | |
| 7221 | 7219 | TypeTableEntry *bool_type = ira->codegen->builtin_types.entry_bool; |
| ... | ... | @@ -7298,13 +7296,13 @@ static TypeTableEntry *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp |
| 7298 | 7296 | |
| 7299 | 7297 | IrInstruction *instructions[] = {op1, op2}; |
| 7300 | 7298 | TypeTableEntry *resolved_type = ir_resolve_peer_types(ira, bin_op_instruction->base.source_node, instructions, 2); |
| 7301 | | if (resolved_type->id == TypeTableEntryIdInvalid) |
| 7299 | if (type_is_invalid(resolved_type)) |
| 7302 | 7300 | return resolved_type; |
| 7303 | 7301 | |
| 7304 | 7302 | AstNode *source_node = bin_op_instruction->base.source_node; |
| 7305 | 7303 | switch (resolved_type->id) { |
| 7306 | 7304 | case TypeTableEntryIdInvalid: |
| 7307 | | return ira->codegen->builtin_types.entry_invalid; |
| 7305 | zig_unreachable(); // handled above |
| 7308 | 7306 | |
| 7309 | 7307 | case TypeTableEntryIdNumLitFloat: |
| 7310 | 7308 | case TypeTableEntryIdNumLitInt: |
| ... | ... | @@ -7532,7 +7530,7 @@ static TypeTableEntry *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp |
| 7532 | 7530 | IrInstruction *op2 = bin_op_instruction->op2->other; |
| 7533 | 7531 | IrInstruction *instructions[] = {op1, op2}; |
| 7534 | 7532 | TypeTableEntry *resolved_type = ir_resolve_peer_types(ira, bin_op_instruction->base.source_node, instructions, 2); |
| 7535 | | if (resolved_type->id == TypeTableEntryIdInvalid) |
| 7533 | if (type_is_invalid(resolved_type)) |
| 7536 | 7534 | return resolved_type; |
| 7537 | 7535 | TypeTableEntry *canon_resolved_type = get_underlying_type(resolved_type); |
| 7538 | 7536 | IrBinOp op_id = bin_op_instruction->op_id; |
| ... | ... | @@ -7602,12 +7600,12 @@ static TypeTableEntry *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp |
| 7602 | 7600 | static TypeTableEntry *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *instruction) { |
| 7603 | 7601 | IrInstruction *op1 = instruction->op1->other; |
| 7604 | 7602 | TypeTableEntry *op1_canon_type = get_underlying_type(op1->value.type); |
| 7605 | | if (op1_canon_type->id == TypeTableEntryIdInvalid) |
| 7603 | if (type_is_invalid(op1_canon_type)) |
| 7606 | 7604 | return ira->codegen->builtin_types.entry_invalid; |
| 7607 | 7605 | |
| 7608 | 7606 | IrInstruction *op2 = instruction->op2->other; |
| 7609 | 7607 | TypeTableEntry *op2_canon_type = get_underlying_type(op2->value.type); |
| 7610 | | if (op2_canon_type->id == TypeTableEntryIdInvalid) |
| 7608 | if (type_is_invalid(op2_canon_type)) |
| 7611 | 7609 | return ira->codegen->builtin_types.entry_invalid; |
| 7612 | 7610 | |
| 7613 | 7611 | ConstExprValue *op1_val = ir_resolve_const(ira, op1, UndefBad); |
| ... | ... | @@ -7741,11 +7739,11 @@ static TypeTableEntry *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp * |
| 7741 | 7739 | |
| 7742 | 7740 | static TypeTableEntry *ir_analyze_array_mult(IrAnalyze *ira, IrInstructionBinOp *instruction) { |
| 7743 | 7741 | IrInstruction *op1 = instruction->op1->other; |
| 7744 | | if (op1->value.type->id == TypeTableEntryIdInvalid) |
| 7742 | if (type_is_invalid(op1->value.type)) |
| 7745 | 7743 | return ira->codegen->builtin_types.entry_invalid; |
| 7746 | 7744 | |
| 7747 | 7745 | IrInstruction *op2 = instruction->op2->other; |
| 7748 | | if (op2->value.type->id == TypeTableEntryIdInvalid) |
| 7746 | if (type_is_invalid(op2->value.type)) |
| 7749 | 7747 | return ira->codegen->builtin_types.entry_invalid; |
| 7750 | 7748 | |
| 7751 | 7749 | ConstExprValue *array_val = ir_resolve_const(ira, op1, UndefBad); |
| ... | ... | @@ -7832,7 +7830,7 @@ static TypeTableEntry *ir_analyze_instruction_decl_var(IrAnalyze *ira, IrInstruc |
| 7832 | 7830 | VariableTableEntry *var = decl_var_instruction->var; |
| 7833 | 7831 | |
| 7834 | 7832 | IrInstruction *init_value = decl_var_instruction->init_value->other; |
| 7835 | | if (init_value->value.type->id == TypeTableEntryIdInvalid) { |
| 7833 | if (type_is_invalid(init_value->value.type)) { |
| 7836 | 7834 | var->value.type = ira->codegen->builtin_types.entry_invalid; |
| 7837 | 7835 | return var->value.type; |
| 7838 | 7836 | } |
| ... | ... | @@ -7849,7 +7847,7 @@ static TypeTableEntry *ir_analyze_instruction_decl_var(IrAnalyze *ira, IrInstruc |
| 7849 | 7847 | var_type = decl_var_instruction->var_type->other; |
| 7850 | 7848 | TypeTableEntry *proposed_type = ir_resolve_type(ira, var_type); |
| 7851 | 7849 | explicit_type = validate_var_type(ira->codegen, var_type->source_node, proposed_type); |
| 7852 | | if (explicit_type->id == TypeTableEntryIdInvalid) { |
| 7850 | if (type_is_invalid(explicit_type)) { |
| 7853 | 7851 | var->value.type = ira->codegen->builtin_types.entry_invalid; |
| 7854 | 7852 | return var->value.type; |
| 7855 | 7853 | } |
| ... | ... | @@ -7859,12 +7857,15 @@ static TypeTableEntry *ir_analyze_instruction_decl_var(IrAnalyze *ira, IrInstruc |
| 7859 | 7857 | |
| 7860 | 7858 | IrInstruction *casted_init_value = ir_implicit_cast(ira, init_value, explicit_type); |
| 7861 | 7859 | TypeTableEntry *result_type = get_underlying_type(casted_init_value->value.type); |
| 7860 | if (type_is_invalid(result_type)) { |
| 7861 | result_type = ira->codegen->builtin_types.entry_invalid; |
| 7862 | } |
| 7863 | |
| 7862 | 7864 | switch (result_type->id) { |
| 7863 | 7865 | case TypeTableEntryIdTypeDecl: |
| 7864 | 7866 | zig_unreachable(); |
| 7865 | 7867 | case TypeTableEntryIdInvalid: |
| 7866 | | result_type = ira->codegen->builtin_types.entry_invalid; |
| 7867 | | break; |
| 7868 | break; // handled above |
| 7868 | 7869 | case TypeTableEntryIdNumLitFloat: |
| 7869 | 7870 | case TypeTableEntryIdNumLitInt: |
| 7870 | 7871 | if (is_export || is_extern || casted_init_value->value.special == ConstValSpecialRuntime) { |
| ... | ... | @@ -7912,7 +7913,7 @@ static TypeTableEntry *ir_analyze_instruction_decl_var(IrAnalyze *ira, IrInstruc |
| 7912 | 7913 | var->value.type = result_type; |
| 7913 | 7914 | assert(var->value.type); |
| 7914 | 7915 | |
| 7915 | | if (result_type->id == TypeTableEntryIdInvalid) { |
| 7916 | if (type_is_invalid(result_type)) { |
| 7916 | 7917 | decl_var_instruction->base.other = &decl_var_instruction->base; |
| 7917 | 7918 | return ira->codegen->builtin_types.entry_void; |
| 7918 | 7919 | } |
| ... | ... | @@ -7953,11 +7954,11 @@ static bool ir_analyze_fn_call_inline_arg(IrAnalyze *ira, AstNode *fn_proto_node |
| 7953 | 7954 | assert(param_decl_node->type == NodeTypeParamDecl); |
| 7954 | 7955 | AstNode *param_type_node = param_decl_node->data.param_decl.type; |
| 7955 | 7956 | TypeTableEntry *param_type = analyze_type_expr(ira->codegen, *exec_scope, param_type_node); |
| 7956 | | if (param_type->id == TypeTableEntryIdInvalid) |
| 7957 | if (type_is_invalid(param_type)) |
| 7957 | 7958 | return false; |
| 7958 | 7959 | |
| 7959 | 7960 | IrInstruction *casted_arg = ir_implicit_cast(ira, arg, param_type); |
| 7960 | | if (casted_arg->value.type->id == TypeTableEntryIdInvalid) |
| 7961 | if (type_is_invalid(casted_arg->value.type)) |
| 7961 | 7962 | return false; |
| 7962 | 7963 | |
| 7963 | 7964 | ConstExprValue *arg_val = ir_resolve_const(ira, casted_arg, UndefBad); |
| ... | ... | @@ -7989,7 +7990,7 @@ static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_nod |
| 7989 | 7990 | } else { |
| 7990 | 7991 | AstNode *param_type_node = param_decl_node->data.param_decl.type; |
| 7991 | 7992 | TypeTableEntry *param_type = analyze_type_expr(ira->codegen, *child_scope, param_type_node); |
| 7992 | | if (param_type->id == TypeTableEntryIdInvalid) |
| 7993 | if (type_is_invalid(param_type)) |
| 7993 | 7994 | return false; |
| 7994 | 7995 | |
| 7995 | 7996 | bool is_var_type = (param_type->id == TypeTableEntryIdVar); |
| ... | ... | @@ -7998,7 +7999,7 @@ static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_nod |
| 7998 | 7999 | casted_arg = arg; |
| 7999 | 8000 | } else { |
| 8000 | 8001 | casted_arg = ir_implicit_cast(ira, arg, param_type); |
| 8001 | | if (casted_arg->value.type->id == TypeTableEntryIdInvalid) |
| 8002 | if (type_is_invalid(casted_arg->value.type)) |
| 8002 | 8003 | return false; |
| 8003 | 8004 | } |
| 8004 | 8005 | } |
| ... | ... | @@ -8102,7 +8103,7 @@ static TypeTableEntry *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *cal |
| 8102 | 8103 | first_arg = first_arg_ptr; |
| 8103 | 8104 | } else { |
| 8104 | 8105 | first_arg = ir_get_deref(ira, first_arg_ptr, first_arg_ptr); |
| 8105 | | if (first_arg->value.type->id == TypeTableEntryIdInvalid) |
| 8106 | if (type_is_invalid(first_arg->value.type)) |
| 8106 | 8107 | return ira->codegen->builtin_types.entry_invalid; |
| 8107 | 8108 | } |
| 8108 | 8109 | |
| ... | ... | @@ -8112,7 +8113,7 @@ static TypeTableEntry *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *cal |
| 8112 | 8113 | |
| 8113 | 8114 | for (size_t call_i = 0; call_i < call_instruction->arg_count; call_i += 1) { |
| 8114 | 8115 | IrInstruction *old_arg = call_instruction->args[call_i]->other; |
| 8115 | | if (old_arg->value.type->id == TypeTableEntryIdInvalid) |
| 8116 | if (type_is_invalid(old_arg->value.type)) |
| 8116 | 8117 | return ira->codegen->builtin_types.entry_invalid; |
| 8117 | 8118 | |
| 8118 | 8119 | if (!ir_analyze_fn_call_inline_arg(ira, fn_proto_node, old_arg, &exec_scope, &next_proto_i)) |
| ... | ... | @@ -8121,7 +8122,7 @@ static TypeTableEntry *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *cal |
| 8121 | 8122 | |
| 8122 | 8123 | AstNode *return_type_node = fn_proto_node->data.fn_proto.return_type; |
| 8123 | 8124 | TypeTableEntry *return_type = analyze_type_expr(ira->codegen, exec_scope, return_type_node); |
| 8124 | | if (return_type->id == TypeTableEntryIdInvalid) |
| 8125 | if (type_is_invalid(return_type)) |
| 8125 | 8126 | return ira->codegen->builtin_types.entry_invalid; |
| 8126 | 8127 | |
| 8127 | 8128 | IrInstruction *result; |
| ... | ... | @@ -8135,7 +8136,7 @@ static TypeTableEntry *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *cal |
| 8135 | 8136 | result = ir_eval_const_value(ira->codegen, exec_scope, body_node, return_type, |
| 8136 | 8137 | ira->new_irb.exec->backward_branch_count, ira->new_irb.exec->backward_branch_quota, fn_entry, |
| 8137 | 8138 | nullptr, call_instruction->base.source_node, nullptr, ira->new_irb.exec); |
| 8138 | | if (result->value.type->id == TypeTableEntryIdInvalid) |
| 8139 | if (type_is_invalid(result->value.type)) |
| 8139 | 8140 | return ira->codegen->builtin_types.entry_invalid; |
| 8140 | 8141 | |
| 8141 | 8142 | ira->codegen->memoized_fn_eval_table.put(exec_scope, result); |
| ... | ... | @@ -8178,7 +8179,7 @@ static TypeTableEntry *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *cal |
| 8178 | 8179 | first_arg = first_arg_ptr; |
| 8179 | 8180 | } else { |
| 8180 | 8181 | first_arg = ir_get_deref(ira, first_arg_ptr, first_arg_ptr); |
| 8181 | | if (first_arg->value.type->id == TypeTableEntryIdInvalid) |
| 8182 | if (type_is_invalid(first_arg->value.type)) |
| 8182 | 8183 | return ira->codegen->builtin_types.entry_invalid; |
| 8183 | 8184 | } |
| 8184 | 8185 | |
| ... | ... | @@ -8193,7 +8194,7 @@ static TypeTableEntry *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *cal |
| 8193 | 8194 | size_t first_var_arg = inst_fn_type_id.param_count; |
| 8194 | 8195 | for (size_t call_i = 0; call_i < call_instruction->arg_count; call_i += 1) { |
| 8195 | 8196 | IrInstruction *arg = call_instruction->args[call_i]->other; |
| 8196 | | if (arg->value.type->id == TypeTableEntryIdInvalid) |
| 8197 | if (type_is_invalid(arg->value.type)) |
| 8197 | 8198 | return ira->codegen->builtin_types.entry_invalid; |
| 8198 | 8199 | |
| 8199 | 8200 | AstNode *param_decl_node = fn_proto_node->data.fn_proto.params.at(next_proto_i); |
| ... | ... | @@ -8224,7 +8225,7 @@ static TypeTableEntry *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *cal |
| 8224 | 8225 | { |
| 8225 | 8226 | AstNode *return_type_node = fn_proto_node->data.fn_proto.return_type; |
| 8226 | 8227 | TypeTableEntry *return_type = analyze_type_expr(ira->codegen, impl_fn->child_scope, return_type_node); |
| 8227 | | if (return_type->id == TypeTableEntryIdInvalid) |
| 8228 | if (type_is_invalid(return_type)) |
| 8228 | 8229 | return ira->codegen->builtin_types.entry_invalid; |
| 8229 | 8230 | inst_fn_type_id.return_type = return_type; |
| 8230 | 8231 | |
| ... | ... | @@ -8241,7 +8242,7 @@ static TypeTableEntry *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *cal |
| 8241 | 8242 | } else { |
| 8242 | 8243 | // finish instantiating the function |
| 8243 | 8244 | impl_fn->type_entry = get_fn_type(ira->codegen, &inst_fn_type_id); |
| 8244 | | if (impl_fn->type_entry->id == TypeTableEntryIdInvalid) |
| 8245 | if (type_is_invalid(impl_fn->type_entry)) |
| 8245 | 8246 | return ira->codegen->builtin_types.entry_invalid; |
| 8246 | 8247 | |
| 8247 | 8248 | impl_fn->ir_executable.source_node = call_instruction->base.source_node; |
| ... | ... | @@ -8272,16 +8273,16 @@ static TypeTableEntry *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *cal |
| 8272 | 8273 | first_arg = first_arg_ptr; |
| 8273 | 8274 | } else { |
| 8274 | 8275 | first_arg = ir_get_deref(ira, first_arg_ptr, first_arg_ptr); |
| 8275 | | if (first_arg->value.type->id == TypeTableEntryIdInvalid) |
| 8276 | if (type_is_invalid(first_arg->value.type)) |
| 8276 | 8277 | return ira->codegen->builtin_types.entry_invalid; |
| 8277 | 8278 | } |
| 8278 | 8279 | |
| 8279 | 8280 | TypeTableEntry *param_type = fn_type_id->param_info[next_arg_index].type; |
| 8280 | | if (param_type->id == TypeTableEntryIdInvalid) |
| 8281 | if (type_is_invalid(param_type)) |
| 8281 | 8282 | return ira->codegen->builtin_types.entry_invalid; |
| 8282 | 8283 | |
| 8283 | 8284 | IrInstruction *casted_arg = ir_implicit_cast(ira, first_arg, param_type); |
| 8284 | | if (casted_arg->value.type->id == TypeTableEntryIdInvalid) |
| 8285 | if (type_is_invalid(casted_arg->value.type)) |
| 8285 | 8286 | return ira->codegen->builtin_types.entry_invalid; |
| 8286 | 8287 | |
| 8287 | 8288 | casted_args[next_arg_index] = casted_arg; |
| ... | ... | @@ -8289,15 +8290,15 @@ static TypeTableEntry *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *cal |
| 8289 | 8290 | } |
| 8290 | 8291 | for (size_t call_i = 0; call_i < call_instruction->arg_count; call_i += 1) { |
| 8291 | 8292 | IrInstruction *old_arg = call_instruction->args[call_i]->other; |
| 8292 | | if (old_arg->value.type->id == TypeTableEntryIdInvalid) |
| 8293 | if (type_is_invalid(old_arg->value.type)) |
| 8293 | 8294 | return ira->codegen->builtin_types.entry_invalid; |
| 8294 | 8295 | IrInstruction *casted_arg; |
| 8295 | 8296 | if (next_arg_index < src_param_count) { |
| 8296 | 8297 | TypeTableEntry *param_type = fn_type_id->param_info[next_arg_index].type; |
| 8297 | | if (param_type->id == TypeTableEntryIdInvalid) |
| 8298 | if (type_is_invalid(param_type)) |
| 8298 | 8299 | return ira->codegen->builtin_types.entry_invalid; |
| 8299 | 8300 | casted_arg = ir_implicit_cast(ira, old_arg, param_type); |
| 8300 | | if (casted_arg->value.type->id == TypeTableEntryIdInvalid) |
| 8301 | if (type_is_invalid(casted_arg->value.type)) |
| 8301 | 8302 | return ira->codegen->builtin_types.entry_invalid; |
| 8302 | 8303 | } else { |
| 8303 | 8304 | casted_arg = old_arg; |
| ... | ... | @@ -8310,7 +8311,7 @@ static TypeTableEntry *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *cal |
| 8310 | 8311 | assert(next_arg_index == call_param_count); |
| 8311 | 8312 | |
| 8312 | 8313 | TypeTableEntry *return_type = fn_type_id->return_type; |
| 8313 | | if (return_type->id == TypeTableEntryIdInvalid) |
| 8314 | if (type_is_invalid(return_type)) |
| 8314 | 8315 | return ira->codegen->builtin_types.entry_invalid; |
| 8315 | 8316 | |
| 8316 | 8317 | IrInstruction *new_call_instruction = ir_build_call_from(&ira->new_irb, &call_instruction->base, |
| ... | ... | @@ -8322,7 +8323,7 @@ static TypeTableEntry *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *cal |
| 8322 | 8323 | |
| 8323 | 8324 | static TypeTableEntry *ir_analyze_instruction_call(IrAnalyze *ira, IrInstructionCall *call_instruction) { |
| 8324 | 8325 | IrInstruction *fn_ref = call_instruction->fn_ref->other; |
| 8325 | | if (fn_ref->value.type->id == TypeTableEntryIdInvalid) |
| 8326 | if (type_is_invalid(fn_ref->value.type)) |
| 8326 | 8327 | return ira->codegen->builtin_types.entry_invalid; |
| 8327 | 8328 | |
| 8328 | 8329 | bool is_inline = call_instruction->is_comptime || |
| ... | ... | @@ -8331,7 +8332,7 @@ static TypeTableEntry *ir_analyze_instruction_call(IrAnalyze *ira, IrInstruction |
| 8331 | 8332 | if (is_inline || instr_is_comptime(fn_ref)) { |
| 8332 | 8333 | if (fn_ref->value.type->id == TypeTableEntryIdMetaType) { |
| 8333 | 8334 | TypeTableEntry *dest_type = ir_resolve_type(ira, fn_ref); |
| 8334 | | if (dest_type->id == TypeTableEntryIdInvalid) |
| 8335 | if (type_is_invalid(dest_type)) |
| 8335 | 8336 | return ira->codegen->builtin_types.entry_invalid; |
| 8336 | 8337 | |
| 8337 | 8338 | size_t actual_param_count = call_instruction->arg_count; |
| ... | ... | @@ -8345,7 +8346,7 @@ static TypeTableEntry *ir_analyze_instruction_call(IrAnalyze *ira, IrInstruction |
| 8345 | 8346 | IrInstruction *arg = call_instruction->args[0]->other; |
| 8346 | 8347 | |
| 8347 | 8348 | IrInstruction *cast_instruction = ir_analyze_cast(ira, &call_instruction->base, dest_type, arg); |
| 8348 | | if (cast_instruction->value.type->id == TypeTableEntryIdInvalid) |
| 8349 | if (type_is_invalid(cast_instruction->value.type)) |
| 8349 | 8350 | return ira->codegen->builtin_types.entry_invalid; |
| 8350 | 8351 | |
| 8351 | 8352 | ir_link_new_instruction(cast_instruction, &call_instruction->base); |
| ... | ... | @@ -8383,11 +8384,16 @@ static TypeTableEntry *ir_analyze_unary_prefix_op_err(IrAnalyze *ira, IrInstruct |
| 8383 | 8384 | |
| 8384 | 8385 | TypeTableEntry *meta_type = ir_resolve_type(ira, value); |
| 8385 | 8386 | TypeTableEntry *underlying_meta_type = get_underlying_type(meta_type); |
| 8387 | |
| 8388 | if (type_is_invalid(underlying_meta_type)) |
| 8389 | return ira->codegen->builtin_types.entry_invalid; |
| 8390 | |
| 8391 | |
| 8386 | 8392 | switch (underlying_meta_type->id) { |
| 8387 | 8393 | case TypeTableEntryIdTypeDecl: |
| 8394 | case TypeTableEntryIdInvalid: // handled above |
| 8388 | 8395 | zig_unreachable(); |
| 8389 | | case TypeTableEntryIdInvalid: |
| 8390 | | return ira->codegen->builtin_types.entry_invalid; |
| 8396 | |
| 8391 | 8397 | case TypeTableEntryIdVoid: |
| 8392 | 8398 | case TypeTableEntryIdBool: |
| 8393 | 8399 | case TypeTableEntryIdInt: |
| ... | ... | @@ -8433,7 +8439,7 @@ static TypeTableEntry *ir_analyze_dereference(IrAnalyze *ira, IrInstructionUnOp |
| 8433 | 8439 | |
| 8434 | 8440 | TypeTableEntry *ptr_type = value->value.type; |
| 8435 | 8441 | TypeTableEntry *child_type; |
| 8436 | | if (ptr_type->id == TypeTableEntryIdInvalid) { |
| 8442 | if (type_is_invalid(ptr_type)) { |
| 8437 | 8443 | return ira->codegen->builtin_types.entry_invalid; |
| 8438 | 8444 | } else if (ptr_type->id == TypeTableEntryIdPointer) { |
| 8439 | 8445 | child_type = ptr_type->data.pointer.child_type; |
| ... | ... | @@ -8509,7 +8515,7 @@ static TypeTableEntry *ir_analyze_maybe(IrAnalyze *ira, IrInstructionUnOp *un_op |
| 8509 | 8515 | static TypeTableEntry *ir_analyze_negation(IrAnalyze *ira, IrInstructionUnOp *un_op_instruction) { |
| 8510 | 8516 | IrInstruction *value = un_op_instruction->value->other; |
| 8511 | 8517 | TypeTableEntry *expr_type = value->value.type; |
| 8512 | | if (expr_type->id == TypeTableEntryIdInvalid) |
| 8518 | if (type_is_invalid(expr_type)) |
| 8513 | 8519 | return ira->codegen->builtin_types.entry_invalid; |
| 8514 | 8520 | |
| 8515 | 8521 | bool is_wrap_op = (un_op_instruction->op_id == IrUnOpNegationWrap); |
| ... | ... | @@ -8555,7 +8561,7 @@ static TypeTableEntry *ir_analyze_negation(IrAnalyze *ira, IrInstructionUnOp *un |
| 8555 | 8561 | static TypeTableEntry *ir_analyze_bin_not(IrAnalyze *ira, IrInstructionUnOp *instruction) { |
| 8556 | 8562 | IrInstruction *value = instruction->value->other; |
| 8557 | 8563 | TypeTableEntry *expr_type = value->value.type; |
| 8558 | | if (expr_type->id == TypeTableEntryIdInvalid) |
| 8564 | if (type_is_invalid(expr_type)) |
| 8559 | 8565 | return ira->codegen->builtin_types.entry_invalid; |
| 8560 | 8566 | |
| 8561 | 8567 | if (expr_type->id == TypeTableEntryIdInt) { |
| ... | ... | @@ -8616,7 +8622,7 @@ static TypeTableEntry *ir_analyze_instruction_br(IrAnalyze *ira, IrInstructionBr |
| 8616 | 8622 | |
| 8617 | 8623 | static TypeTableEntry *ir_analyze_instruction_cond_br(IrAnalyze *ira, IrInstructionCondBr *cond_br_instruction) { |
| 8618 | 8624 | IrInstruction *condition = cond_br_instruction->condition->other; |
| 8619 | | if (condition->value.type->id == TypeTableEntryIdInvalid) |
| 8625 | if (type_is_invalid(condition->value.type)) |
| 8620 | 8626 | return ir_unreach_error(ira); |
| 8621 | 8627 | |
| 8622 | 8628 | bool is_comptime; |
| ... | ... | @@ -8667,7 +8673,7 @@ static TypeTableEntry *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionP |
| 8667 | 8673 | continue; |
| 8668 | 8674 | IrInstruction *value = phi_instruction->incoming_values[i]->other; |
| 8669 | 8675 | assert(value->value.type); |
| 8670 | | if (value->value.type->id == TypeTableEntryIdInvalid) |
| 8676 | if (type_is_invalid(value->value.type)) |
| 8671 | 8677 | return ira->codegen->builtin_types.entry_invalid; |
| 8672 | 8678 | |
| 8673 | 8679 | if (value->value.special != ConstValSpecialRuntime) { |
| ... | ... | @@ -8696,7 +8702,7 @@ static TypeTableEntry *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionP |
| 8696 | 8702 | if (!new_value || new_value->value.type->id == TypeTableEntryIdUnreachable) |
| 8697 | 8703 | continue; |
| 8698 | 8704 | |
| 8699 | | if (new_value->value.type->id == TypeTableEntryIdInvalid) |
| 8705 | if (type_is_invalid(new_value->value.type)) |
| 8700 | 8706 | return ira->codegen->builtin_types.entry_invalid; |
| 8701 | 8707 | |
| 8702 | 8708 | |
| ... | ... | @@ -8718,7 +8724,7 @@ static TypeTableEntry *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionP |
| 8718 | 8724 | |
| 8719 | 8725 | TypeTableEntry *resolved_type = ir_resolve_peer_types(ira, phi_instruction->base.source_node, |
| 8720 | 8726 | new_incoming_values.items, new_incoming_values.length); |
| 8721 | | if (resolved_type->id == TypeTableEntryIdInvalid) |
| 8727 | if (type_is_invalid(resolved_type)) |
| 8722 | 8728 | return resolved_type; |
| 8723 | 8729 | |
| 8724 | 8730 | if (resolved_type->id == TypeTableEntryIdNumLitFloat || |
| ... | ... | @@ -8756,7 +8762,7 @@ static TypeTableEntry *ir_analyze_var_ptr(IrAnalyze *ira, IrInstruction *instruc |
| 8756 | 8762 | VariableTableEntry *var, bool is_const_ptr, bool is_volatile_ptr) |
| 8757 | 8763 | { |
| 8758 | 8764 | assert(var->value.type); |
| 8759 | | if (var->value.type->id == TypeTableEntryIdInvalid) |
| 8765 | if (type_is_invalid(var->value.type)) |
| 8760 | 8766 | return var->value.type; |
| 8761 | 8767 | |
| 8762 | 8768 | bool comptime_var_mem = ir_get_var_is_comptime(var); |
| ... | ... | @@ -8816,11 +8822,11 @@ static VariableTableEntry *get_fn_var_by_index(FnTableEntry *fn_entry, size_t in |
| 8816 | 8822 | |
| 8817 | 8823 | static TypeTableEntry *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstructionElemPtr *elem_ptr_instruction) { |
| 8818 | 8824 | IrInstruction *array_ptr = elem_ptr_instruction->array_ptr->other; |
| 8819 | | if (array_ptr->value.type->id == TypeTableEntryIdInvalid) |
| 8825 | if (type_is_invalid(array_ptr->value.type)) |
| 8820 | 8826 | return ira->codegen->builtin_types.entry_invalid; |
| 8821 | 8827 | |
| 8822 | 8828 | IrInstruction *elem_index = elem_ptr_instruction->elem_index->other; |
| 8823 | | if (elem_index->value.type->id == TypeTableEntryIdInvalid) |
| 8829 | if (type_is_invalid(elem_index->value.type)) |
| 8824 | 8830 | return ira->codegen->builtin_types.entry_invalid; |
| 8825 | 8831 | |
| 8826 | 8832 | // This will be a pointer type because elem ptr IR instruction operates on a pointer to a thing. |
| ... | ... | @@ -8830,7 +8836,7 @@ static TypeTableEntry *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruc |
| 8830 | 8836 | TypeTableEntry *array_type = ptr_type->data.pointer.child_type; |
| 8831 | 8837 | TypeTableEntry *return_type; |
| 8832 | 8838 | |
| 8833 | | if (array_type->id == TypeTableEntryIdInvalid) { |
| 8839 | if (type_is_invalid(array_type)) { |
| 8834 | 8840 | return array_type; |
| 8835 | 8841 | } else if (array_type->id == TypeTableEntryIdArray) { |
| 8836 | 8842 | if (array_type->data.array.len == 0) { |
| ... | ... | @@ -9019,7 +9025,7 @@ static TypeTableEntry *ir_analyze_container_member_access_inner(IrAnalyze *ira, |
| 9019 | 9025 | return ira->codegen->builtin_types.entry_invalid; |
| 9020 | 9026 | TldFn *tld_fn = (TldFn *)tld; |
| 9021 | 9027 | FnTableEntry *fn_entry = tld_fn->fn_entry; |
| 9022 | | if (fn_entry->type_entry->id == TypeTableEntryIdInvalid) |
| 9028 | if (type_is_invalid(fn_entry->type_entry)) |
| 9023 | 9029 | return ira->codegen->builtin_types.entry_invalid; |
| 9024 | 9030 | |
| 9025 | 9031 | IrInstruction *bound_fn_value = ir_build_const_bound_fn(&ira->new_irb, field_ptr_instruction->base.scope, |
| ... | ... | @@ -9113,7 +9119,7 @@ static TypeTableEntry *ir_analyze_decl_ref(IrAnalyze *ira, IrInstruction *source |
| 9113 | 9119 | FnTableEntry *fn_entry = tld_fn->fn_entry; |
| 9114 | 9120 | assert(fn_entry->type_entry); |
| 9115 | 9121 | |
| 9116 | | if (fn_entry->type_entry->id == TypeTableEntryIdInvalid) |
| 9122 | if (type_is_invalid(fn_entry->type_entry)) |
| 9117 | 9123 | return ira->codegen->builtin_types.entry_invalid; |
| 9118 | 9124 | |
| 9119 | 9125 | // TODO instead of allocating this every time, put it in the tld value and we can reference |
| ... | ... | @@ -9151,7 +9157,7 @@ static TypeTableEntry *ir_analyze_decl_ref(IrAnalyze *ira, IrInstruction *source |
| 9151 | 9157 | |
| 9152 | 9158 | static TypeTableEntry *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstructionFieldPtr *field_ptr_instruction) { |
| 9153 | 9159 | IrInstruction *container_ptr = field_ptr_instruction->container_ptr->other; |
| 9154 | | if (container_ptr->value.type->id == TypeTableEntryIdInvalid) |
| 9160 | if (type_is_invalid(container_ptr->value.type)) |
| 9155 | 9161 | return ira->codegen->builtin_types.entry_invalid; |
| 9156 | 9162 | |
| 9157 | 9163 | TypeTableEntry *container_type; |
| ... | ... | @@ -9166,7 +9172,7 @@ static TypeTableEntry *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstru |
| 9166 | 9172 | Buf *field_name = field_ptr_instruction->field_name; |
| 9167 | 9173 | AstNode *source_node = field_ptr_instruction->base.source_node; |
| 9168 | 9174 | |
| 9169 | | if (container_type->id == TypeTableEntryIdInvalid) { |
| 9175 | if (type_is_invalid(container_type)) { |
| 9170 | 9176 | return container_type; |
| 9171 | 9177 | } else if (is_container_ref(container_type)) { |
| 9172 | 9178 | assert(container_ptr->value.type->id == TypeTableEntryIdPointer); |
| ... | ... | @@ -9234,7 +9240,7 @@ static TypeTableEntry *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstru |
| 9234 | 9240 | zig_unreachable(); |
| 9235 | 9241 | } |
| 9236 | 9242 | |
| 9237 | | if (child_type->id == TypeTableEntryIdInvalid) { |
| 9243 | if (type_is_invalid(child_type)) { |
| 9238 | 9244 | return ira->codegen->builtin_types.entry_invalid; |
| 9239 | 9245 | } else if (is_container(child_type)) { |
| 9240 | 9246 | if (child_type->id == TypeTableEntryIdEnum) { |
| ... | ... | @@ -9371,11 +9377,11 @@ static TypeTableEntry *ir_analyze_instruction_load_ptr(IrAnalyze *ira, IrInstruc |
| 9371 | 9377 | |
| 9372 | 9378 | static TypeTableEntry *ir_analyze_instruction_store_ptr(IrAnalyze *ira, IrInstructionStorePtr *store_ptr_instruction) { |
| 9373 | 9379 | IrInstruction *ptr = store_ptr_instruction->ptr->other; |
| 9374 | | if (ptr->value.type->id == TypeTableEntryIdInvalid) |
| 9380 | if (type_is_invalid(ptr->value.type)) |
| 9375 | 9381 | return ptr->value.type; |
| 9376 | 9382 | |
| 9377 | 9383 | IrInstruction *value = store_ptr_instruction->value->other; |
| 9378 | | if (value->value.type->id == TypeTableEntryIdInvalid) |
| 9384 | if (type_is_invalid(value->value.type)) |
| 9379 | 9385 | return value->value.type; |
| 9380 | 9386 | |
| 9381 | 9387 | assert(ptr->value.type->id == TypeTableEntryIdPointer); |
| ... | ... | @@ -9412,9 +9418,11 @@ static TypeTableEntry *ir_analyze_instruction_store_ptr(IrAnalyze *ira, IrInstru |
| 9412 | 9418 | static TypeTableEntry *ir_analyze_instruction_typeof(IrAnalyze *ira, IrInstructionTypeOf *typeof_instruction) { |
| 9413 | 9419 | IrInstruction *expr_value = typeof_instruction->value->other; |
| 9414 | 9420 | TypeTableEntry *type_entry = expr_value->value.type; |
| 9421 | if (type_is_invalid(type_entry)) |
| 9422 | return ira->codegen->builtin_types.entry_invalid; |
| 9415 | 9423 | switch (type_entry->id) { |
| 9416 | 9424 | case TypeTableEntryIdInvalid: |
| 9417 | | return type_entry; |
| 9425 | zig_unreachable(); // handled above |
| 9418 | 9426 | case TypeTableEntryIdVar: |
| 9419 | 9427 | ir_add_error_node(ira, expr_value->source_node, |
| 9420 | 9428 | buf_sprintf("type '%s' not eligible for @typeOf", buf_ptr(&type_entry->name))); |
| ... | ... | @@ -9460,7 +9468,7 @@ static TypeTableEntry *ir_analyze_instruction_to_ptr_type(IrAnalyze *ira, |
| 9460 | 9468 | { |
| 9461 | 9469 | IrInstruction *value = to_ptr_type_instruction->value->other; |
| 9462 | 9470 | TypeTableEntry *type_entry = value->value.type; |
| 9463 | | if (type_entry->id == TypeTableEntryIdInvalid) |
| 9471 | if (type_is_invalid(type_entry)) |
| 9464 | 9472 | return type_entry; |
| 9465 | 9473 | |
| 9466 | 9474 | TypeTableEntry *ptr_type; |
| ... | ... | @@ -9489,7 +9497,7 @@ static TypeTableEntry *ir_analyze_instruction_ptr_type_child(IrAnalyze *ira, |
| 9489 | 9497 | { |
| 9490 | 9498 | IrInstruction *type_value = ptr_type_child_instruction->value->other; |
| 9491 | 9499 | TypeTableEntry *type_entry = ir_resolve_type(ira, type_value); |
| 9492 | | if (type_entry->id == TypeTableEntryIdInvalid) |
| 9500 | if (type_is_invalid(type_entry)) |
| 9493 | 9501 | return type_entry; |
| 9494 | 9502 | |
| 9495 | 9503 | // TODO handle typedefs |
| ... | ... | @@ -9651,7 +9659,7 @@ static TypeTableEntry *ir_analyze_instruction_set_debug_safety(IrAnalyze *ira, |
| 9651 | 9659 | { |
| 9652 | 9660 | IrInstruction *target_instruction = set_debug_safety_instruction->scope_value->other; |
| 9653 | 9661 | TypeTableEntry *target_type = target_instruction->value.type; |
| 9654 | | if (target_type->id == TypeTableEntryIdInvalid) |
| 9662 | if (type_is_invalid(target_type)) |
| 9655 | 9663 | return ira->codegen->builtin_types.entry_invalid; |
| 9656 | 9664 | ConstExprValue *target_val = ir_resolve_const(ira, target_instruction, UndefBad); |
| 9657 | 9665 | if (!target_val) |
| ... | ... | @@ -9719,17 +9727,19 @@ static TypeTableEntry *ir_analyze_instruction_slice_type(IrAnalyze *ira, |
| 9719 | 9727 | IrInstructionSliceType *slice_type_instruction) |
| 9720 | 9728 | { |
| 9721 | 9729 | IrInstruction *child_type = slice_type_instruction->child_type->other; |
| 9722 | | if (child_type->value.type->id == TypeTableEntryIdInvalid) |
| 9730 | if (type_is_invalid(child_type->value.type)) |
| 9723 | 9731 | return ira->codegen->builtin_types.entry_invalid; |
| 9724 | 9732 | bool is_const = slice_type_instruction->is_const; |
| 9725 | 9733 | |
| 9726 | 9734 | TypeTableEntry *resolved_child_type = ir_resolve_type(ira, child_type); |
| 9727 | 9735 | TypeTableEntry *canon_child_type = get_underlying_type(resolved_child_type); |
| 9736 | if (type_is_invalid(canon_child_type)) |
| 9737 | return ira->codegen->builtin_types.entry_invalid; |
| 9738 | |
| 9728 | 9739 | switch (canon_child_type->id) { |
| 9729 | 9740 | case TypeTableEntryIdTypeDecl: |
| 9741 | case TypeTableEntryIdInvalid: // handled above |
| 9730 | 9742 | zig_unreachable(); |
| 9731 | | case TypeTableEntryIdInvalid: |
| 9732 | | return ira->codegen->builtin_types.entry_invalid; |
| 9733 | 9743 | case TypeTableEntryIdVar: |
| 9734 | 9744 | case TypeTableEntryIdUnreachable: |
| 9735 | 9745 | case TypeTableEntryIdUndefLit: |
| ... | ... | @@ -9789,14 +9799,14 @@ static TypeTableEntry *ir_analyze_instruction_asm(IrAnalyze *ira, IrInstructionA |
| 9789 | 9799 | if (asm_output->return_type) { |
| 9790 | 9800 | output_types[i] = asm_instruction->output_types[i]->other; |
| 9791 | 9801 | return_type = ir_resolve_type(ira, output_types[i]); |
| 9792 | | if (return_type->id == TypeTableEntryIdInvalid) |
| 9802 | if (type_is_invalid(return_type)) |
| 9793 | 9803 | return ira->codegen->builtin_types.entry_invalid; |
| 9794 | 9804 | } |
| 9795 | 9805 | } |
| 9796 | 9806 | |
| 9797 | 9807 | for (size_t i = 0; i < asm_expr->input_list.length; i += 1) { |
| 9798 | 9808 | input_list[i] = asm_instruction->input_list[i]->other; |
| 9799 | | if (input_list[i]->value.type->id == TypeTableEntryIdInvalid) |
| 9809 | if (type_is_invalid(input_list[i]->value.type)) |
| 9800 | 9810 | return ira->codegen->builtin_types.entry_invalid; |
| 9801 | 9811 | } |
| 9802 | 9812 | |
| ... | ... | @@ -9816,11 +9826,12 @@ static TypeTableEntry *ir_analyze_instruction_array_type(IrAnalyze *ira, |
| 9816 | 9826 | IrInstruction *child_type_value = array_type_instruction->child_type->other; |
| 9817 | 9827 | TypeTableEntry *child_type = ir_resolve_type(ira, child_type_value); |
| 9818 | 9828 | TypeTableEntry *canon_child_type = get_underlying_type(child_type); |
| 9829 | if (type_is_invalid(canon_child_type)) |
| 9830 | return ira->codegen->builtin_types.entry_invalid; |
| 9819 | 9831 | switch (canon_child_type->id) { |
| 9820 | 9832 | case TypeTableEntryIdTypeDecl: |
| 9833 | case TypeTableEntryIdInvalid: // handled above |
| 9821 | 9834 | zig_unreachable(); |
| 9822 | | case TypeTableEntryIdInvalid: |
| 9823 | | return ira->codegen->builtin_types.entry_invalid; |
| 9824 | 9835 | case TypeTableEntryIdVar: |
| 9825 | 9836 | case TypeTableEntryIdUnreachable: |
| 9826 | 9837 | case TypeTableEntryIdUndefLit: |
| ... | ... | @@ -9906,10 +9917,11 @@ static TypeTableEntry *ir_analyze_instruction_size_of(IrAnalyze *ira, |
| 9906 | 9917 | TypeTableEntry *canon_type_entry = get_underlying_type(type_entry); |
| 9907 | 9918 | |
| 9908 | 9919 | ensure_complete_type(ira->codegen, type_entry); |
| 9920 | if (type_is_invalid(canon_type_entry)) |
| 9921 | return ira->codegen->builtin_types.entry_invalid; |
| 9909 | 9922 | |
| 9910 | 9923 | switch (canon_type_entry->id) { |
| 9911 | | case TypeTableEntryIdInvalid: |
| 9912 | | return ira->codegen->builtin_types.entry_invalid; |
| 9924 | case TypeTableEntryIdInvalid: // handled above |
| 9913 | 9925 | case TypeTableEntryIdTypeDecl: |
| 9914 | 9926 | zig_unreachable(); |
| 9915 | 9927 | case TypeTableEntryIdVar: |
| ... | ... | @@ -9953,7 +9965,7 @@ static TypeTableEntry *ir_analyze_instruction_size_of(IrAnalyze *ira, |
| 9953 | 9965 | |
| 9954 | 9966 | static TypeTableEntry *ir_analyze_instruction_test_non_null(IrAnalyze *ira, IrInstructionTestNonNull *instruction) { |
| 9955 | 9967 | IrInstruction *value = instruction->value->other; |
| 9956 | | if (value->value.type->id == TypeTableEntryIdInvalid) |
| 9968 | if (type_is_invalid(value->value.type)) |
| 9957 | 9969 | return ira->codegen->builtin_types.entry_invalid; |
| 9958 | 9970 | |
| 9959 | 9971 | TypeTableEntry *type_entry = value->value.type; |
| ... | ... | @@ -9986,7 +9998,7 @@ static TypeTableEntry *ir_analyze_instruction_unwrap_maybe(IrAnalyze *ira, |
| 9986 | 9998 | IrInstructionUnwrapMaybe *unwrap_maybe_instruction) |
| 9987 | 9999 | { |
| 9988 | 10000 | IrInstruction *value = unwrap_maybe_instruction->value->other; |
| 9989 | | if (value->value.type->id == TypeTableEntryIdInvalid) |
| 10001 | if (type_is_invalid(value->value.type)) |
| 9990 | 10002 | return ira->codegen->builtin_types.entry_invalid; |
| 9991 | 10003 | |
| 9992 | 10004 | TypeTableEntry *ptr_type = value->value.type; |
| ... | ... | @@ -10010,7 +10022,7 @@ static TypeTableEntry *ir_analyze_instruction_unwrap_maybe(IrAnalyze *ira, |
| 10010 | 10022 | |
| 10011 | 10023 | TypeTableEntry *type_entry = ptr_type->data.pointer.child_type; |
| 10012 | 10024 | // TODO handle typedef |
| 10013 | | if (type_entry->id == TypeTableEntryIdInvalid) { |
| 10025 | if (type_is_invalid(type_entry)) { |
| 10014 | 10026 | return ira->codegen->builtin_types.entry_invalid; |
| 10015 | 10027 | } else if (type_entry->id != TypeTableEntryIdMaybe) { |
| 10016 | 10028 | ir_add_error_node(ira, unwrap_maybe_instruction->value->source_node, |
| ... | ... | @@ -10047,7 +10059,7 @@ static TypeTableEntry *ir_analyze_instruction_unwrap_maybe(IrAnalyze *ira, |
| 10047 | 10059 | |
| 10048 | 10060 | static TypeTableEntry *ir_analyze_instruction_ctz(IrAnalyze *ira, IrInstructionCtz *ctz_instruction) { |
| 10049 | 10061 | IrInstruction *value = ctz_instruction->value->other; |
| 10050 | | if (value->value.type->id == TypeTableEntryIdInvalid) { |
| 10062 | if (type_is_invalid(value->value.type)) { |
| 10051 | 10063 | return ira->codegen->builtin_types.entry_invalid; |
| 10052 | 10064 | } else if (value->value.type->id == TypeTableEntryIdInt) { |
| 10053 | 10065 | if (value->value.special != ConstValSpecialRuntime) { |
| ... | ... | @@ -10069,7 +10081,7 @@ static TypeTableEntry *ir_analyze_instruction_ctz(IrAnalyze *ira, IrInstructionC |
| 10069 | 10081 | |
| 10070 | 10082 | static TypeTableEntry *ir_analyze_instruction_clz(IrAnalyze *ira, IrInstructionClz *clz_instruction) { |
| 10071 | 10083 | IrInstruction *value = clz_instruction->value->other; |
| 10072 | | if (value->value.type->id == TypeTableEntryIdInvalid) { |
| 10084 | if (type_is_invalid(value->value.type)) { |
| 10073 | 10085 | return ira->codegen->builtin_types.entry_invalid; |
| 10074 | 10086 | } else if (value->value.type->id == TypeTableEntryIdInt) { |
| 10075 | 10087 | if (value->value.special != ConstValSpecialRuntime) { |
| ... | ... | @@ -10090,7 +10102,7 @@ static TypeTableEntry *ir_analyze_instruction_clz(IrAnalyze *ira, IrInstructionC |
| 10090 | 10102 | } |
| 10091 | 10103 | |
| 10092 | 10104 | static IrInstruction *ir_analyze_enum_tag(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *value) { |
| 10093 | | if (value->value.type->id == TypeTableEntryIdInvalid) |
| 10105 | if (type_is_invalid(value->value.type)) |
| 10094 | 10106 | return ira->codegen->invalid_instruction; |
| 10095 | 10107 | |
| 10096 | 10108 | if (value->value.type->id != TypeTableEntryIdEnum) { |
| ... | ... | @@ -10119,7 +10131,7 @@ static TypeTableEntry *ir_analyze_instruction_switch_br(IrAnalyze *ira, |
| 10119 | 10131 | IrInstructionSwitchBr *switch_br_instruction) |
| 10120 | 10132 | { |
| 10121 | 10133 | IrInstruction *target_value = switch_br_instruction->target_value->other; |
| 10122 | | if (target_value->value.type->id == TypeTableEntryIdInvalid) |
| 10134 | if (type_is_invalid(target_value->value.type)) |
| 10123 | 10135 | return ir_unreach_error(ira); |
| 10124 | 10136 | |
| 10125 | 10137 | size_t case_count = switch_br_instruction->case_count; |
| ... | ... | @@ -10137,17 +10149,17 @@ static TypeTableEntry *ir_analyze_instruction_switch_br(IrAnalyze *ira, |
| 10137 | 10149 | for (size_t i = 0; i < case_count; i += 1) { |
| 10138 | 10150 | IrInstructionSwitchBrCase *old_case = &switch_br_instruction->cases[i]; |
| 10139 | 10151 | IrInstruction *case_value = old_case->value->other; |
| 10140 | | if (case_value->value.type->id == TypeTableEntryIdInvalid) |
| 10152 | if (type_is_invalid(case_value->value.type)) |
| 10141 | 10153 | return ir_unreach_error(ira); |
| 10142 | 10154 | |
| 10143 | 10155 | if (case_value->value.type->id == TypeTableEntryIdEnum) { |
| 10144 | 10156 | case_value = ir_analyze_enum_tag(ira, &switch_br_instruction->base, case_value); |
| 10145 | | if (case_value->value.type->id == TypeTableEntryIdInvalid) |
| 10157 | if (type_is_invalid(case_value->value.type)) |
| 10146 | 10158 | return ir_unreach_error(ira); |
| 10147 | 10159 | } |
| 10148 | 10160 | |
| 10149 | 10161 | IrInstruction *casted_case_value = ir_implicit_cast(ira, case_value, target_value->value.type); |
| 10150 | | if (casted_case_value->value.type->id == TypeTableEntryIdInvalid) |
| 10162 | if (type_is_invalid(casted_case_value->value.type)) |
| 10151 | 10163 | return ir_unreach_error(ira); |
| 10152 | 10164 | |
| 10153 | 10165 | ConstExprValue *case_val = ir_resolve_const(ira, casted_case_value, UndefBad); |
| ... | ... | @@ -10184,17 +10196,17 @@ static TypeTableEntry *ir_analyze_instruction_switch_br(IrAnalyze *ira, |
| 10184 | 10196 | |
| 10185 | 10197 | IrInstruction *old_value = old_case->value; |
| 10186 | 10198 | IrInstruction *new_value = old_value->other; |
| 10187 | | if (new_value->value.type->id == TypeTableEntryIdInvalid) |
| 10199 | if (type_is_invalid(new_value->value.type)) |
| 10188 | 10200 | continue; |
| 10189 | 10201 | |
| 10190 | 10202 | if (new_value->value.type->id == TypeTableEntryIdEnum) { |
| 10191 | 10203 | new_value = ir_analyze_enum_tag(ira, &switch_br_instruction->base, new_value); |
| 10192 | | if (new_value->value.type->id == TypeTableEntryIdInvalid) |
| 10204 | if (type_is_invalid(new_value->value.type)) |
| 10193 | 10205 | continue; |
| 10194 | 10206 | } |
| 10195 | 10207 | |
| 10196 | 10208 | IrInstruction *casted_new_value = ir_implicit_cast(ira, new_value, target_value->value.type); |
| 10197 | | if (casted_new_value->value.type->id == TypeTableEntryIdInvalid) |
| 10209 | if (type_is_invalid(casted_new_value->value.type)) |
| 10198 | 10210 | continue; |
| 10199 | 10211 | |
| 10200 | 10212 | if (!ir_resolve_const(ira, casted_new_value, UndefBad)) |
| ... | ... | @@ -10218,7 +10230,7 @@ static TypeTableEntry *ir_analyze_instruction_switch_target(IrAnalyze *ira, |
| 10218 | 10230 | IrInstructionSwitchTarget *switch_target_instruction) |
| 10219 | 10231 | { |
| 10220 | 10232 | IrInstruction *target_value_ptr = switch_target_instruction->target_value_ptr->other; |
| 10221 | | if (target_value_ptr->value.type->id == TypeTableEntryIdInvalid) |
| 10233 | if (type_is_invalid(target_value_ptr->value.type)) |
| 10222 | 10234 | return ira->codegen->builtin_types.entry_invalid; |
| 10223 | 10235 | |
| 10224 | 10236 | assert(target_value_ptr->value.type->id == TypeTableEntryIdPointer); |
| ... | ... | @@ -10231,6 +10243,8 @@ static TypeTableEntry *ir_analyze_instruction_switch_target(IrAnalyze *ira, |
| 10231 | 10243 | } |
| 10232 | 10244 | TypeTableEntry *canon_target_type = get_underlying_type(target_type); |
| 10233 | 10245 | ensure_complete_type(ira->codegen, target_type); |
| 10246 | if (type_is_invalid(canon_target_type)) |
| 10247 | return ira->codegen->builtin_types.entry_invalid; |
| 10234 | 10248 | |
| 10235 | 10249 | switch (canon_target_type->id) { |
| 10236 | 10250 | case TypeTableEntryIdInvalid: |
| ... | ... | @@ -10297,11 +10311,11 @@ static TypeTableEntry *ir_analyze_instruction_switch_target(IrAnalyze *ira, |
| 10297 | 10311 | |
| 10298 | 10312 | static TypeTableEntry *ir_analyze_instruction_switch_var(IrAnalyze *ira, IrInstructionSwitchVar *instruction) { |
| 10299 | 10313 | IrInstruction *target_value_ptr = instruction->target_value_ptr->other; |
| 10300 | | if (target_value_ptr->value.type->id == TypeTableEntryIdInvalid) |
| 10314 | if (type_is_invalid(target_value_ptr->value.type)) |
| 10301 | 10315 | return ira->codegen->builtin_types.entry_invalid; |
| 10302 | 10316 | |
| 10303 | 10317 | IrInstruction *prong_value = instruction->prong_value->other; |
| 10304 | | if (prong_value->value.type->id == TypeTableEntryIdInvalid) |
| 10318 | if (type_is_invalid(prong_value->value.type)) |
| 10305 | 10319 | return ira->codegen->builtin_types.entry_invalid; |
| 10306 | 10320 | |
| 10307 | 10321 | assert(target_value_ptr->value.type->id == TypeTableEntryIdPointer); |
| ... | ... | @@ -10357,7 +10371,7 @@ static TypeTableEntry *ir_analyze_instruction_enum_tag(IrAnalyze *ira, IrInstruc |
| 10357 | 10371 | |
| 10358 | 10372 | static TypeTableEntry *ir_analyze_instruction_generated_code(IrAnalyze *ira, IrInstructionGeneratedCode *instruction) { |
| 10359 | 10373 | IrInstruction *value = instruction->value->other; |
| 10360 | | if (value->value.type->id == TypeTableEntryIdInvalid) |
| 10374 | if (type_is_invalid(value->value.type)) |
| 10361 | 10375 | return ira->codegen->builtin_types.entry_invalid; |
| 10362 | 10376 | |
| 10363 | 10377 | if (instr_is_comptime(value)) { |
| ... | ... | @@ -10452,7 +10466,7 @@ static TypeTableEntry *ir_analyze_instruction_array_len(IrAnalyze *ira, |
| 10452 | 10466 | { |
| 10453 | 10467 | IrInstruction *array_value = array_len_instruction->array_value->other; |
| 10454 | 10468 | TypeTableEntry *canon_type = get_underlying_type(array_value->value.type); |
| 10455 | | if (canon_type->id == TypeTableEntryIdInvalid) { |
| 10469 | if (type_is_invalid(canon_type)) { |
| 10456 | 10470 | return ira->codegen->builtin_types.entry_invalid; |
| 10457 | 10471 | } else if (canon_type->id == TypeTableEntryIdArray) { |
| 10458 | 10472 | return ir_analyze_const_usize(ira, &array_len_instruction->base, |
| ... | ... | @@ -10515,7 +10529,7 @@ static TypeTableEntry *ir_analyze_container_init_fields(IrAnalyze *ira, IrInstru |
| 10515 | 10529 | IrInstructionContainerInitFieldsField *field = &fields[i]; |
| 10516 | 10530 | |
| 10517 | 10531 | IrInstruction *field_value = field->value->other; |
| 10518 | | if (field_value->value.type->id == TypeTableEntryIdInvalid) |
| 10532 | if (type_is_invalid(field_value->value.type)) |
| 10519 | 10533 | return ira->codegen->builtin_types.entry_invalid; |
| 10520 | 10534 | |
| 10521 | 10535 | TypeStructField *type_field = find_struct_type_field(container_type, field->name); |
| ... | ... | @@ -10526,7 +10540,7 @@ static TypeTableEntry *ir_analyze_container_init_fields(IrAnalyze *ira, IrInstru |
| 10526 | 10540 | return ira->codegen->builtin_types.entry_invalid; |
| 10527 | 10541 | } |
| 10528 | 10542 | |
| 10529 | | if (type_field->type_entry->id == TypeTableEntryIdInvalid) |
| 10543 | if (type_is_invalid(type_field->type_entry)) |
| 10530 | 10544 | return ira->codegen->builtin_types.entry_invalid; |
| 10531 | 10545 | |
| 10532 | 10546 | IrInstruction *casted_field_value = ir_implicit_cast(ira, field_value, type_field->type_entry); |
| ... | ... | @@ -10593,13 +10607,13 @@ static TypeTableEntry *ir_analyze_instruction_container_init_list(IrAnalyze *ira |
| 10593 | 10607 | IrInstructionContainerInitList *instruction) |
| 10594 | 10608 | { |
| 10595 | 10609 | IrInstruction *container_type_value = instruction->container_type->other; |
| 10596 | | if (container_type_value->value.type->id == TypeTableEntryIdInvalid) |
| 10610 | if (type_is_invalid(container_type_value->value.type)) |
| 10597 | 10611 | return ira->codegen->builtin_types.entry_invalid; |
| 10598 | 10612 | |
| 10599 | 10613 | size_t elem_count = instruction->item_count; |
| 10600 | 10614 | if (container_type_value->value.type->id == TypeTableEntryIdMetaType) { |
| 10601 | 10615 | TypeTableEntry *container_type = ir_resolve_type(ira, container_type_value); |
| 10602 | | if (container_type->id == TypeTableEntryIdInvalid) |
| 10616 | if (type_is_invalid(container_type)) |
| 10603 | 10617 | return ira->codegen->builtin_types.entry_invalid; |
| 10604 | 10618 | |
| 10605 | 10619 | if (container_type->id == TypeTableEntryIdStruct && !is_slice(container_type) && elem_count == 0) { |
| ... | ... | @@ -10624,7 +10638,7 @@ static TypeTableEntry *ir_analyze_instruction_container_init_list(IrAnalyze *ira |
| 10624 | 10638 | |
| 10625 | 10639 | for (size_t i = 0; i < elem_count; i += 1) { |
| 10626 | 10640 | IrInstruction *arg_value = instruction->items[i]->other; |
| 10627 | | if (arg_value->value.type->id == TypeTableEntryIdInvalid) |
| 10641 | if (type_is_invalid(arg_value->value.type)) |
| 10628 | 10642 | return ira->codegen->builtin_types.entry_invalid; |
| 10629 | 10643 | |
| 10630 | 10644 | IrInstruction *casted_arg = ir_implicit_cast(ira, arg_value, child_type); |
| ... | ... | @@ -10744,9 +10758,11 @@ static TypeTableEntry *ir_analyze_min_max(IrAnalyze *ira, IrInstruction *source_ |
| 10744 | 10758 | { |
| 10745 | 10759 | TypeTableEntry *target_type = ir_resolve_type(ira, target_type_value); |
| 10746 | 10760 | TypeTableEntry *canon_type = get_underlying_type(target_type); |
| 10761 | if (type_is_invalid(canon_type)) |
| 10762 | return ira->codegen->builtin_types.entry_invalid; |
| 10747 | 10763 | switch (canon_type->id) { |
| 10748 | 10764 | case TypeTableEntryIdInvalid: |
| 10749 | | return ira->codegen->builtin_types.entry_invalid; |
| 10765 | zig_unreachable(); |
| 10750 | 10766 | case TypeTableEntryIdInt: |
| 10751 | 10767 | { |
| 10752 | 10768 | ConstExprValue *out_val = ir_build_const_from(ira, source_instruction); |
| ... | ... | @@ -10831,7 +10847,7 @@ static TypeTableEntry *ir_analyze_instruction_compile_log(IrAnalyze *ira, IrInst |
| 10831 | 10847 | fprintf(stderr, "| "); |
| 10832 | 10848 | for (size_t i = 0; i < instruction->msg_count; i += 1) { |
| 10833 | 10849 | IrInstruction *msg = instruction->msg_list[i]->other; |
| 10834 | | if (msg->value.type->id == TypeTableEntryIdInvalid) |
| 10850 | if (type_is_invalid(msg->value.type)) |
| 10835 | 10851 | return ira->codegen->builtin_types.entry_invalid; |
| 10836 | 10852 | buf_resize(&buf, 0); |
| 10837 | 10853 | render_const_value(&buf, &msg->value); |
| ... | ... | @@ -10848,11 +10864,11 @@ static TypeTableEntry *ir_analyze_instruction_compile_log(IrAnalyze *ira, IrInst |
| 10848 | 10864 | |
| 10849 | 10865 | static TypeTableEntry *ir_analyze_instruction_err_name(IrAnalyze *ira, IrInstructionErrName *instruction) { |
| 10850 | 10866 | IrInstruction *value = instruction->value->other; |
| 10851 | | if (value->value.type->id == TypeTableEntryIdInvalid) |
| 10867 | if (type_is_invalid(value->value.type)) |
| 10852 | 10868 | return ira->codegen->builtin_types.entry_invalid; |
| 10853 | 10869 | |
| 10854 | 10870 | IrInstruction *casted_value = ir_implicit_cast(ira, value, value->value.type); |
| 10855 | | if (casted_value->value.type->id == TypeTableEntryIdInvalid) |
| 10871 | if (type_is_invalid(casted_value->value.type)) |
| 10856 | 10872 | return ira->codegen->builtin_types.entry_invalid; |
| 10857 | 10873 | |
| 10858 | 10874 | TypeTableEntry *str_type = get_slice_type(ira->codegen, ira->codegen->builtin_types.entry_u8, true); |
| ... | ... | @@ -10875,7 +10891,7 @@ static TypeTableEntry *ir_analyze_instruction_err_name(IrAnalyze *ira, IrInstruc |
| 10875 | 10891 | static TypeTableEntry *ir_analyze_instruction_type_name(IrAnalyze *ira, IrInstructionTypeName *instruction) { |
| 10876 | 10892 | IrInstruction *type_value = instruction->type_value->other; |
| 10877 | 10893 | TypeTableEntry *type_entry = ir_resolve_type(ira, type_value); |
| 10878 | | if (type_entry->id == TypeTableEntryIdInvalid) |
| 10894 | if (type_is_invalid(type_entry)) |
| 10879 | 10895 | return ira->codegen->builtin_types.entry_invalid; |
| 10880 | 10896 | |
| 10881 | 10897 | if (!type_entry->cached_const_name_val) { |
| ... | ... | @@ -10898,7 +10914,7 @@ static TypeTableEntry *ir_analyze_instruction_c_import(IrAnalyze *ira, IrInstruc |
| 10898 | 10914 | IrInstruction *result = ir_eval_const_value(ira->codegen, &cimport_scope->base, block_node, void_type, |
| 10899 | 10915 | ira->new_irb.exec->backward_branch_count, ira->new_irb.exec->backward_branch_quota, nullptr, |
| 10900 | 10916 | &cimport_scope->buf, block_node, nullptr, nullptr); |
| 10901 | | if (result->value.type->id == TypeTableEntryIdInvalid) |
| 10917 | if (type_is_invalid(result->value.type)) |
| 10902 | 10918 | return ira->codegen->builtin_types.entry_invalid; |
| 10903 | 10919 | |
| 10904 | 10920 | find_libc_include_path(ira->codegen); |
| ... | ... | @@ -10937,7 +10953,7 @@ static TypeTableEntry *ir_analyze_instruction_c_import(IrAnalyze *ira, IrInstruc |
| 10937 | 10953 | |
| 10938 | 10954 | static TypeTableEntry *ir_analyze_instruction_c_include(IrAnalyze *ira, IrInstructionCInclude *instruction) { |
| 10939 | 10955 | IrInstruction *name_value = instruction->name->other; |
| 10940 | | if (name_value->value.type->id == TypeTableEntryIdInvalid) |
| 10956 | if (type_is_invalid(name_value->value.type)) |
| 10941 | 10957 | return ira->codegen->builtin_types.entry_invalid; |
| 10942 | 10958 | |
| 10943 | 10959 | Buf *include_name = ir_resolve_str(ira, name_value); |
| ... | ... | @@ -10956,7 +10972,7 @@ static TypeTableEntry *ir_analyze_instruction_c_include(IrAnalyze *ira, IrInstru |
| 10956 | 10972 | |
| 10957 | 10973 | static TypeTableEntry *ir_analyze_instruction_c_define(IrAnalyze *ira, IrInstructionCDefine *instruction) { |
| 10958 | 10974 | IrInstruction *name = instruction->name->other; |
| 10959 | | if (name->value.type->id == TypeTableEntryIdInvalid) |
| 10975 | if (type_is_invalid(name->value.type)) |
| 10960 | 10976 | return ira->codegen->builtin_types.entry_invalid; |
| 10961 | 10977 | |
| 10962 | 10978 | Buf *define_name = ir_resolve_str(ira, name); |
| ... | ... | @@ -10964,7 +10980,7 @@ static TypeTableEntry *ir_analyze_instruction_c_define(IrAnalyze *ira, IrInstruc |
| 10964 | 10980 | return ira->codegen->builtin_types.entry_invalid; |
| 10965 | 10981 | |
| 10966 | 10982 | IrInstruction *value = instruction->value->other; |
| 10967 | | if (value->value.type->id == TypeTableEntryIdInvalid) |
| 10983 | if (type_is_invalid(value->value.type)) |
| 10968 | 10984 | return ira->codegen->builtin_types.entry_invalid; |
| 10969 | 10985 | |
| 10970 | 10986 | Buf *define_value = ir_resolve_str(ira, value); |
| ... | ... | @@ -10983,7 +10999,7 @@ static TypeTableEntry *ir_analyze_instruction_c_define(IrAnalyze *ira, IrInstruc |
| 10983 | 10999 | |
| 10984 | 11000 | static TypeTableEntry *ir_analyze_instruction_c_undef(IrAnalyze *ira, IrInstructionCUndef *instruction) { |
| 10985 | 11001 | IrInstruction *name = instruction->name->other; |
| 10986 | | if (name->value.type->id == TypeTableEntryIdInvalid) |
| 11002 | if (type_is_invalid(name->value.type)) |
| 10987 | 11003 | return ira->codegen->builtin_types.entry_invalid; |
| 10988 | 11004 | |
| 10989 | 11005 | Buf *undef_name = ir_resolve_str(ira, name); |
| ... | ... | @@ -11002,7 +11018,7 @@ static TypeTableEntry *ir_analyze_instruction_c_undef(IrAnalyze *ira, IrInstruct |
| 11002 | 11018 | |
| 11003 | 11019 | static TypeTableEntry *ir_analyze_instruction_embed_file(IrAnalyze *ira, IrInstructionEmbedFile *instruction) { |
| 11004 | 11020 | IrInstruction *name = instruction->name->other; |
| 11005 | | if (name->value.type->id == TypeTableEntryIdInvalid) |
| 11021 | if (type_is_invalid(name->value.type)) |
| 11006 | 11022 | return ira->codegen->builtin_types.entry_invalid; |
| 11007 | 11023 | |
| 11008 | 11024 | Buf *rel_file_path = ir_resolve_str(ira, name); |
| ... | ... | @@ -11041,19 +11057,19 @@ static TypeTableEntry *ir_analyze_instruction_embed_file(IrAnalyze *ira, IrInstr |
| 11041 | 11057 | |
| 11042 | 11058 | static TypeTableEntry *ir_analyze_instruction_cmpxchg(IrAnalyze *ira, IrInstructionCmpxchg *instruction) { |
| 11043 | 11059 | IrInstruction *ptr = instruction->ptr->other; |
| 11044 | | if (ptr->value.type->id == TypeTableEntryIdInvalid) |
| 11060 | if (type_is_invalid(ptr->value.type)) |
| 11045 | 11061 | return ira->codegen->builtin_types.entry_invalid; |
| 11046 | 11062 | |
| 11047 | 11063 | IrInstruction *cmp_value = instruction->cmp_value->other; |
| 11048 | | if (cmp_value->value.type->id == TypeTableEntryIdInvalid) |
| 11064 | if (type_is_invalid(cmp_value->value.type)) |
| 11049 | 11065 | return ira->codegen->builtin_types.entry_invalid; |
| 11050 | 11066 | |
| 11051 | 11067 | IrInstruction *new_value = instruction->new_value->other; |
| 11052 | | if (new_value->value.type->id == TypeTableEntryIdInvalid) |
| 11068 | if (type_is_invalid(new_value->value.type)) |
| 11053 | 11069 | return ira->codegen->builtin_types.entry_invalid; |
| 11054 | 11070 | |
| 11055 | 11071 | IrInstruction *success_order_value = instruction->success_order_value->other; |
| 11056 | | if (success_order_value->value.type->id == TypeTableEntryIdInvalid) |
| 11072 | if (type_is_invalid(success_order_value->value.type)) |
| 11057 | 11073 | return ira->codegen->builtin_types.entry_invalid; |
| 11058 | 11074 | |
| 11059 | 11075 | AtomicOrder success_order; |
| ... | ... | @@ -11061,7 +11077,7 @@ static TypeTableEntry *ir_analyze_instruction_cmpxchg(IrAnalyze *ira, IrInstruct |
| 11061 | 11077 | return ira->codegen->builtin_types.entry_invalid; |
| 11062 | 11078 | |
| 11063 | 11079 | IrInstruction *failure_order_value = instruction->failure_order_value->other; |
| 11064 | | if (failure_order_value->value.type->id == TypeTableEntryIdInvalid) |
| 11080 | if (type_is_invalid(failure_order_value->value.type)) |
| 11065 | 11081 | return ira->codegen->builtin_types.entry_invalid; |
| 11066 | 11082 | |
| 11067 | 11083 | AtomicOrder failure_order; |
| ... | ... | @@ -11077,11 +11093,11 @@ static TypeTableEntry *ir_analyze_instruction_cmpxchg(IrAnalyze *ira, IrInstruct |
| 11077 | 11093 | TypeTableEntry *child_type = ptr->value.type->data.pointer.child_type; |
| 11078 | 11094 | |
| 11079 | 11095 | IrInstruction *casted_cmp_value = ir_implicit_cast(ira, cmp_value, child_type); |
| 11080 | | if (casted_cmp_value->value.type->id == TypeTableEntryIdInvalid) |
| 11096 | if (type_is_invalid(casted_cmp_value->value.type)) |
| 11081 | 11097 | return ira->codegen->builtin_types.entry_invalid; |
| 11082 | 11098 | |
| 11083 | 11099 | IrInstruction *casted_new_value = ir_implicit_cast(ira, new_value, child_type); |
| 11084 | | if (casted_new_value->value.type->id == TypeTableEntryIdInvalid) |
| 11100 | if (type_is_invalid(casted_new_value->value.type)) |
| 11085 | 11101 | return ira->codegen->builtin_types.entry_invalid; |
| 11086 | 11102 | |
| 11087 | 11103 | if (success_order < AtomicOrderMonotonic) { |
| ... | ... | @@ -11112,7 +11128,7 @@ static TypeTableEntry *ir_analyze_instruction_cmpxchg(IrAnalyze *ira, IrInstruct |
| 11112 | 11128 | |
| 11113 | 11129 | static TypeTableEntry *ir_analyze_instruction_fence(IrAnalyze *ira, IrInstructionFence *instruction) { |
| 11114 | 11130 | IrInstruction *order_value = instruction->order_value->other; |
| 11115 | | if (order_value->value.type->id == TypeTableEntryIdInvalid) |
| 11131 | if (type_is_invalid(order_value->value.type)) |
| 11116 | 11132 | return ira->codegen->builtin_types.entry_invalid; |
| 11117 | 11133 | |
| 11118 | 11134 | AtomicOrder order; |
| ... | ... | @@ -11125,18 +11141,18 @@ static TypeTableEntry *ir_analyze_instruction_fence(IrAnalyze *ira, IrInstructio |
| 11125 | 11141 | |
| 11126 | 11142 | static TypeTableEntry *ir_analyze_instruction_div_exact(IrAnalyze *ira, IrInstructionDivExact *instruction) { |
| 11127 | 11143 | IrInstruction *op1 = instruction->op1->other; |
| 11128 | | if (op1->value.type->id == TypeTableEntryIdInvalid) |
| 11144 | if (type_is_invalid(op1->value.type)) |
| 11129 | 11145 | return ira->codegen->builtin_types.entry_invalid; |
| 11130 | 11146 | |
| 11131 | 11147 | IrInstruction *op2 = instruction->op2->other; |
| 11132 | | if (op2->value.type->id == TypeTableEntryIdInvalid) |
| 11148 | if (type_is_invalid(op2->value.type)) |
| 11133 | 11149 | return ira->codegen->builtin_types.entry_invalid; |
| 11134 | 11150 | |
| 11135 | 11151 | |
| 11136 | 11152 | IrInstruction *peer_instructions[] = { op1, op2 }; |
| 11137 | 11153 | TypeTableEntry *result_type = ir_resolve_peer_types(ira, instruction->base.source_node, peer_instructions, 2); |
| 11138 | 11154 | |
| 11139 | | if (result_type->id == TypeTableEntryIdInvalid) |
| 11155 | if (type_is_invalid(result_type)) |
| 11140 | 11156 | return ira->codegen->builtin_types.entry_invalid; |
| 11141 | 11157 | |
| 11142 | 11158 | TypeTableEntry *canon_type = get_underlying_type(result_type); |
| ... | ... | @@ -11151,11 +11167,11 @@ static TypeTableEntry *ir_analyze_instruction_div_exact(IrAnalyze *ira, IrInstru |
| 11151 | 11167 | } |
| 11152 | 11168 | |
| 11153 | 11169 | IrInstruction *casted_op1 = ir_implicit_cast(ira, op1, result_type); |
| 11154 | | if (casted_op1->value.type->id == TypeTableEntryIdInvalid) |
| 11170 | if (type_is_invalid(casted_op1->value.type)) |
| 11155 | 11171 | return ira->codegen->builtin_types.entry_invalid; |
| 11156 | 11172 | |
| 11157 | 11173 | IrInstruction *casted_op2 = ir_implicit_cast(ira, op2, result_type); |
| 11158 | | if (casted_op2->value.type->id == TypeTableEntryIdInvalid) |
| 11174 | if (type_is_invalid(casted_op2->value.type)) |
| 11159 | 11175 | return ira->codegen->builtin_types.entry_invalid; |
| 11160 | 11176 | |
| 11161 | 11177 | if (casted_op1->value.special == ConstValSpecialStatic && |
| ... | ... | @@ -11196,7 +11212,7 @@ static TypeTableEntry *ir_analyze_instruction_truncate(IrAnalyze *ira, IrInstruc |
| 11196 | 11212 | TypeTableEntry *dest_type = ir_resolve_type(ira, dest_type_value); |
| 11197 | 11213 | TypeTableEntry *canon_dest_type = get_underlying_type(dest_type); |
| 11198 | 11214 | |
| 11199 | | if (canon_dest_type->id == TypeTableEntryIdInvalid) |
| 11215 | if (type_is_invalid(canon_dest_type)) |
| 11200 | 11216 | return ira->codegen->builtin_types.entry_invalid; |
| 11201 | 11217 | |
| 11202 | 11218 | if (canon_dest_type->id != TypeTableEntryIdInt && |
| ... | ... | @@ -11210,7 +11226,7 @@ static TypeTableEntry *ir_analyze_instruction_truncate(IrAnalyze *ira, IrInstruc |
| 11210 | 11226 | IrInstruction *target = instruction->target->other; |
| 11211 | 11227 | TypeTableEntry *src_type = target->value.type; |
| 11212 | 11228 | TypeTableEntry *canon_src_type = get_underlying_type(src_type); |
| 11213 | | if (canon_src_type->id == TypeTableEntryIdInvalid) |
| 11229 | if (type_is_invalid(canon_src_type)) |
| 11214 | 11230 | return ira->codegen->builtin_types.entry_invalid; |
| 11215 | 11231 | |
| 11216 | 11232 | if (canon_src_type->id != TypeTableEntryIdInt && |
| ... | ... | @@ -11262,13 +11278,13 @@ static TypeTableEntry *ir_analyze_instruction_int_type(IrAnalyze *ira, IrInstruc |
| 11262 | 11278 | |
| 11263 | 11279 | static TypeTableEntry *ir_analyze_instruction_bool_not(IrAnalyze *ira, IrInstructionBoolNot *instruction) { |
| 11264 | 11280 | IrInstruction *value = instruction->value->other; |
| 11265 | | if (value->value.type->id == TypeTableEntryIdInvalid) |
| 11281 | if (type_is_invalid(value->value.type)) |
| 11266 | 11282 | return ira->codegen->builtin_types.entry_invalid; |
| 11267 | 11283 | |
| 11268 | 11284 | TypeTableEntry *bool_type = ira->codegen->builtin_types.entry_bool; |
| 11269 | 11285 | |
| 11270 | 11286 | IrInstruction *casted_value = ir_implicit_cast(ira, value, bool_type); |
| 11271 | | if (casted_value->value.type->id == TypeTableEntryIdInvalid) |
| 11287 | if (type_is_invalid(casted_value->value.type)) |
| 11272 | 11288 | return ira->codegen->builtin_types.entry_invalid; |
| 11273 | 11289 | |
| 11274 | 11290 | if (casted_value->value.special != ConstValSpecialRuntime) { |
| ... | ... | @@ -11283,11 +11299,11 @@ static TypeTableEntry *ir_analyze_instruction_bool_not(IrAnalyze *ira, IrInstruc |
| 11283 | 11299 | |
| 11284 | 11300 | static TypeTableEntry *ir_analyze_instruction_alloca(IrAnalyze *ira, IrInstructionAlloca *instruction) { |
| 11285 | 11301 | IrInstruction *type_value = instruction->type_value->other; |
| 11286 | | if (type_value->value.type->id == TypeTableEntryIdInvalid) |
| 11302 | if (type_is_invalid(type_value->value.type)) |
| 11287 | 11303 | return ira->codegen->builtin_types.entry_invalid; |
| 11288 | 11304 | |
| 11289 | 11305 | IrInstruction *count_value = instruction->count->other; |
| 11290 | | if (count_value->value.type->id == TypeTableEntryIdInvalid) |
| 11306 | if (type_is_invalid(count_value->value.type)) |
| 11291 | 11307 | return ira->codegen->builtin_types.entry_invalid; |
| 11292 | 11308 | |
| 11293 | 11309 | TypeTableEntry *child_type = ir_resolve_type(ira, type_value); |
| ... | ... | @@ -11308,15 +11324,15 @@ static TypeTableEntry *ir_analyze_instruction_alloca(IrAnalyze *ira, IrInstructi |
| 11308 | 11324 | |
| 11309 | 11325 | static TypeTableEntry *ir_analyze_instruction_memset(IrAnalyze *ira, IrInstructionMemset *instruction) { |
| 11310 | 11326 | IrInstruction *dest_ptr = instruction->dest_ptr->other; |
| 11311 | | if (dest_ptr->value.type->id == TypeTableEntryIdInvalid) |
| 11327 | if (type_is_invalid(dest_ptr->value.type)) |
| 11312 | 11328 | return ira->codegen->builtin_types.entry_invalid; |
| 11313 | 11329 | |
| 11314 | 11330 | IrInstruction *byte_value = instruction->byte->other; |
| 11315 | | if (byte_value->value.type->id == TypeTableEntryIdInvalid) |
| 11331 | if (type_is_invalid(byte_value->value.type)) |
| 11316 | 11332 | return ira->codegen->builtin_types.entry_invalid; |
| 11317 | 11333 | |
| 11318 | 11334 | IrInstruction *count_value = instruction->count->other; |
| 11319 | | if (count_value->value.type->id == TypeTableEntryIdInvalid) |
| 11335 | if (type_is_invalid(count_value->value.type)) |
| 11320 | 11336 | return ira->codegen->builtin_types.entry_invalid; |
| 11321 | 11337 | |
| 11322 | 11338 | TypeTableEntry *dest_uncasted_type = get_underlying_type(dest_ptr->value.type); |
| ... | ... | @@ -11328,15 +11344,15 @@ static TypeTableEntry *ir_analyze_instruction_memset(IrAnalyze *ira, IrInstructi |
| 11328 | 11344 | TypeTableEntry *u8_ptr = get_pointer_to_type_extra(ira->codegen, u8, false, dest_is_volatile, 0, 0); |
| 11329 | 11345 | |
| 11330 | 11346 | IrInstruction *casted_dest_ptr = ir_implicit_cast(ira, dest_ptr, u8_ptr); |
| 11331 | | if (casted_dest_ptr->value.type->id == TypeTableEntryIdInvalid) |
| 11347 | if (type_is_invalid(casted_dest_ptr->value.type)) |
| 11332 | 11348 | return ira->codegen->builtin_types.entry_invalid; |
| 11333 | 11349 | |
| 11334 | 11350 | IrInstruction *casted_byte = ir_implicit_cast(ira, byte_value, u8); |
| 11335 | | if (casted_byte->value.type->id == TypeTableEntryIdInvalid) |
| 11351 | if (type_is_invalid(casted_byte->value.type)) |
| 11336 | 11352 | return ira->codegen->builtin_types.entry_invalid; |
| 11337 | 11353 | |
| 11338 | 11354 | IrInstruction *casted_count = ir_implicit_cast(ira, count_value, usize); |
| 11339 | | if (casted_count->value.type->id == TypeTableEntryIdInvalid) |
| 11355 | if (type_is_invalid(casted_count->value.type)) |
| 11340 | 11356 | return ira->codegen->builtin_types.entry_invalid; |
| 11341 | 11357 | |
| 11342 | 11358 | if (casted_dest_ptr->value.special == ConstValSpecialStatic && |
| ... | ... | @@ -11393,15 +11409,15 @@ static TypeTableEntry *ir_analyze_instruction_memset(IrAnalyze *ira, IrInstructi |
| 11393 | 11409 | |
| 11394 | 11410 | static TypeTableEntry *ir_analyze_instruction_memcpy(IrAnalyze *ira, IrInstructionMemcpy *instruction) { |
| 11395 | 11411 | IrInstruction *dest_ptr = instruction->dest_ptr->other; |
| 11396 | | if (dest_ptr->value.type->id == TypeTableEntryIdInvalid) |
| 11412 | if (type_is_invalid(dest_ptr->value.type)) |
| 11397 | 11413 | return ira->codegen->builtin_types.entry_invalid; |
| 11398 | 11414 | |
| 11399 | 11415 | IrInstruction *src_ptr = instruction->src_ptr->other; |
| 11400 | | if (src_ptr->value.type->id == TypeTableEntryIdInvalid) |
| 11416 | if (type_is_invalid(src_ptr->value.type)) |
| 11401 | 11417 | return ira->codegen->builtin_types.entry_invalid; |
| 11402 | 11418 | |
| 11403 | 11419 | IrInstruction *count_value = instruction->count->other; |
| 11404 | | if (count_value->value.type->id == TypeTableEntryIdInvalid) |
| 11420 | if (type_is_invalid(count_value->value.type)) |
| 11405 | 11421 | return ira->codegen->builtin_types.entry_invalid; |
| 11406 | 11422 | |
| 11407 | 11423 | TypeTableEntry *dest_uncasted_type = get_underlying_type(dest_ptr->value.type); |
| ... | ... | @@ -11417,15 +11433,15 @@ static TypeTableEntry *ir_analyze_instruction_memcpy(IrAnalyze *ira, IrInstructi |
| 11417 | 11433 | TypeTableEntry *u8_ptr_const = get_pointer_to_type_extra(ira->codegen, u8, true, src_is_volatile, 0, 0); |
| 11418 | 11434 | |
| 11419 | 11435 | IrInstruction *casted_dest_ptr = ir_implicit_cast(ira, dest_ptr, u8_ptr_mut); |
| 11420 | | if (casted_dest_ptr->value.type->id == TypeTableEntryIdInvalid) |
| 11436 | if (type_is_invalid(casted_dest_ptr->value.type)) |
| 11421 | 11437 | return ira->codegen->builtin_types.entry_invalid; |
| 11422 | 11438 | |
| 11423 | 11439 | IrInstruction *casted_src_ptr = ir_implicit_cast(ira, src_ptr, u8_ptr_const); |
| 11424 | | if (casted_src_ptr->value.type->id == TypeTableEntryIdInvalid) |
| 11440 | if (type_is_invalid(casted_src_ptr->value.type)) |
| 11425 | 11441 | return ira->codegen->builtin_types.entry_invalid; |
| 11426 | 11442 | |
| 11427 | 11443 | IrInstruction *casted_count = ir_implicit_cast(ira, count_value, usize); |
| 11428 | | if (casted_count->value.type->id == TypeTableEntryIdInvalid) |
| 11444 | if (type_is_invalid(casted_count->value.type)) |
| 11429 | 11445 | return ira->codegen->builtin_types.entry_invalid; |
| 11430 | 11446 | |
| 11431 | 11447 | if (casted_dest_ptr->value.special == ConstValSpecialStatic && |
| ... | ... | @@ -11514,7 +11530,7 @@ static TypeTableEntry *ir_analyze_instruction_memcpy(IrAnalyze *ira, IrInstructi |
| 11514 | 11530 | |
| 11515 | 11531 | static TypeTableEntry *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstructionSlice *instruction) { |
| 11516 | 11532 | IrInstruction *ptr_ptr = instruction->ptr->other; |
| 11517 | | if (ptr_ptr->value.type->id == TypeTableEntryIdInvalid) |
| 11533 | if (type_is_invalid(ptr_ptr->value.type)) |
| 11518 | 11534 | return ira->codegen->builtin_types.entry_invalid; |
| 11519 | 11535 | |
| 11520 | 11536 | TypeTableEntry *ptr_type = ptr_ptr->value.type; |
| ... | ... | @@ -11523,21 +11539,21 @@ static TypeTableEntry *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstructio |
| 11523 | 11539 | TypeTableEntry *canon_array_type = get_underlying_type(non_canon_array_type); |
| 11524 | 11540 | |
| 11525 | 11541 | IrInstruction *start = instruction->start->other; |
| 11526 | | if (start->value.type->id == TypeTableEntryIdInvalid) |
| 11542 | if (type_is_invalid(start->value.type)) |
| 11527 | 11543 | return ira->codegen->builtin_types.entry_invalid; |
| 11528 | 11544 | |
| 11529 | 11545 | TypeTableEntry *usize = ira->codegen->builtin_types.entry_usize; |
| 11530 | 11546 | IrInstruction *casted_start = ir_implicit_cast(ira, start, usize); |
| 11531 | | if (casted_start->value.type->id == TypeTableEntryIdInvalid) |
| 11547 | if (type_is_invalid(casted_start->value.type)) |
| 11532 | 11548 | return ira->codegen->builtin_types.entry_invalid; |
| 11533 | 11549 | |
| 11534 | 11550 | IrInstruction *end; |
| 11535 | 11551 | if (instruction->end) { |
| 11536 | 11552 | end = instruction->end->other; |
| 11537 | | if (end->value.type->id == TypeTableEntryIdInvalid) |
| 11553 | if (type_is_invalid(end->value.type)) |
| 11538 | 11554 | return ira->codegen->builtin_types.entry_invalid; |
| 11539 | 11555 | end = ir_implicit_cast(ira, end, usize); |
| 11540 | | if (end->value.type->id == TypeTableEntryIdInvalid) |
| 11556 | if (type_is_invalid(end->value.type)) |
| 11541 | 11557 | return ira->codegen->builtin_types.entry_invalid; |
| 11542 | 11558 | } else { |
| 11543 | 11559 | end = nullptr; |
| ... | ... | @@ -11692,13 +11708,13 @@ static TypeTableEntry *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstructio |
| 11692 | 11708 | |
| 11693 | 11709 | static TypeTableEntry *ir_analyze_instruction_member_count(IrAnalyze *ira, IrInstructionMemberCount *instruction) { |
| 11694 | 11710 | IrInstruction *container = instruction->container->other; |
| 11695 | | if (container->value.type->id == TypeTableEntryIdInvalid) |
| 11711 | if (type_is_invalid(container->value.type)) |
| 11696 | 11712 | return ira->codegen->builtin_types.entry_invalid; |
| 11697 | 11713 | TypeTableEntry *container_type = ir_resolve_type(ira, container); |
| 11698 | 11714 | TypeTableEntry *canon_type = get_underlying_type(container_type); |
| 11699 | 11715 | |
| 11700 | 11716 | uint64_t result; |
| 11701 | | if (canon_type->id == TypeTableEntryIdInvalid) { |
| 11717 | if (type_is_invalid(canon_type)) { |
| 11702 | 11718 | return ira->codegen->builtin_types.entry_invalid; |
| 11703 | 11719 | } else if (canon_type->id == TypeTableEntryIdEnum) { |
| 11704 | 11720 | result = canon_type->data.enumeration.src_field_count; |
| ... | ... | @@ -11739,11 +11755,11 @@ static TypeTableEntry *ir_analyze_instruction_frame_address(IrAnalyze *ira, IrIn |
| 11739 | 11755 | |
| 11740 | 11756 | static TypeTableEntry *ir_analyze_instruction_alignof(IrAnalyze *ira, IrInstructionAlignOf *instruction) { |
| 11741 | 11757 | IrInstruction *type_value = instruction->type_value->other; |
| 11742 | | if (type_value->value.type->id == TypeTableEntryIdInvalid) |
| 11758 | if (type_is_invalid(type_value->value.type)) |
| 11743 | 11759 | return ira->codegen->builtin_types.entry_invalid; |
| 11744 | 11760 | TypeTableEntry *type_entry = ir_resolve_type(ira, type_value); |
| 11745 | 11761 | |
| 11746 | | if (type_entry->id == TypeTableEntryIdInvalid) { |
| 11762 | if (type_is_invalid(type_entry)) { |
| 11747 | 11763 | return ira->codegen->builtin_types.entry_invalid; |
| 11748 | 11764 | } else if (type_entry->id == TypeTableEntryIdUnreachable) { |
| 11749 | 11765 | ir_add_error(ira, instruction->type_value, |
| ... | ... | @@ -11759,11 +11775,11 @@ static TypeTableEntry *ir_analyze_instruction_alignof(IrAnalyze *ira, IrInstruct |
| 11759 | 11775 | |
| 11760 | 11776 | static TypeTableEntry *ir_analyze_instruction_overflow_op(IrAnalyze *ira, IrInstructionOverflowOp *instruction) { |
| 11761 | 11777 | IrInstruction *type_value = instruction->type_value->other; |
| 11762 | | if (type_value->value.type->id == TypeTableEntryIdInvalid) |
| 11778 | if (type_is_invalid(type_value->value.type)) |
| 11763 | 11779 | return ira->codegen->builtin_types.entry_invalid; |
| 11764 | 11780 | TypeTableEntry *dest_type = ir_resolve_type(ira, type_value); |
| 11765 | 11781 | TypeTableEntry *canon_type = get_underlying_type(dest_type); |
| 11766 | | if (canon_type->id == TypeTableEntryIdInvalid) |
| 11782 | if (type_is_invalid(canon_type)) |
| 11767 | 11783 | return ira->codegen->builtin_types.entry_invalid; |
| 11768 | 11784 | |
| 11769 | 11785 | if (canon_type->id != TypeTableEntryIdInt) { |
| ... | ... | @@ -11774,28 +11790,28 @@ static TypeTableEntry *ir_analyze_instruction_overflow_op(IrAnalyze *ira, IrInst |
| 11774 | 11790 | } |
| 11775 | 11791 | |
| 11776 | 11792 | IrInstruction *op1 = instruction->op1->other; |
| 11777 | | if (op1->value.type->id == TypeTableEntryIdInvalid) |
| 11793 | if (type_is_invalid(op1->value.type)) |
| 11778 | 11794 | return ira->codegen->builtin_types.entry_invalid; |
| 11779 | 11795 | |
| 11780 | 11796 | IrInstruction *casted_op1 = ir_implicit_cast(ira, op1, dest_type); |
| 11781 | | if (casted_op1->value.type->id == TypeTableEntryIdInvalid) |
| 11797 | if (type_is_invalid(casted_op1->value.type)) |
| 11782 | 11798 | return ira->codegen->builtin_types.entry_invalid; |
| 11783 | 11799 | |
| 11784 | 11800 | IrInstruction *op2 = instruction->op2->other; |
| 11785 | | if (op2->value.type->id == TypeTableEntryIdInvalid) |
| 11801 | if (type_is_invalid(op2->value.type)) |
| 11786 | 11802 | return ira->codegen->builtin_types.entry_invalid; |
| 11787 | 11803 | |
| 11788 | 11804 | IrInstruction *casted_op2 = ir_implicit_cast(ira, op2, dest_type); |
| 11789 | | if (casted_op2->value.type->id == TypeTableEntryIdInvalid) |
| 11805 | if (type_is_invalid(casted_op2->value.type)) |
| 11790 | 11806 | return ira->codegen->builtin_types.entry_invalid; |
| 11791 | 11807 | |
| 11792 | 11808 | IrInstruction *result_ptr = instruction->result_ptr->other; |
| 11793 | | if (result_ptr->value.type->id == TypeTableEntryIdInvalid) |
| 11809 | if (type_is_invalid(result_ptr->value.type)) |
| 11794 | 11810 | return ira->codegen->builtin_types.entry_invalid; |
| 11795 | 11811 | |
| 11796 | 11812 | TypeTableEntry *expected_ptr_type = get_pointer_to_type(ira->codegen, dest_type, false); |
| 11797 | 11813 | IrInstruction *casted_result_ptr = ir_implicit_cast(ira, result_ptr, expected_ptr_type); |
| 11798 | | if (casted_result_ptr->value.type->id == TypeTableEntryIdInvalid) |
| 11814 | if (type_is_invalid(casted_result_ptr->value.type)) |
| 11799 | 11815 | return ira->codegen->builtin_types.entry_invalid; |
| 11800 | 11816 | |
| 11801 | 11817 | if (casted_op1->value.special == ConstValSpecialStatic && |
| ... | ... | @@ -11838,13 +11854,13 @@ static TypeTableEntry *ir_analyze_instruction_overflow_op(IrAnalyze *ira, IrInst |
| 11838 | 11854 | |
| 11839 | 11855 | static TypeTableEntry *ir_analyze_instruction_test_err(IrAnalyze *ira, IrInstructionTestErr *instruction) { |
| 11840 | 11856 | IrInstruction *value = instruction->value->other; |
| 11841 | | if (value->value.type->id == TypeTableEntryIdInvalid) |
| 11857 | if (type_is_invalid(value->value.type)) |
| 11842 | 11858 | return ira->codegen->builtin_types.entry_invalid; |
| 11843 | 11859 | |
| 11844 | 11860 | TypeTableEntry *non_canon_type = value->value.type; |
| 11845 | 11861 | |
| 11846 | 11862 | TypeTableEntry *canon_type = get_underlying_type(non_canon_type); |
| 11847 | | if (canon_type->id == TypeTableEntryIdInvalid) { |
| 11863 | if (type_is_invalid(canon_type)) { |
| 11848 | 11864 | return ira->codegen->builtin_types.entry_invalid; |
| 11849 | 11865 | } else if (canon_type->id == TypeTableEntryIdErrorUnion) { |
| 11850 | 11866 | if (instr_is_comptime(value)) { |
| ... | ... | @@ -11876,7 +11892,7 @@ static TypeTableEntry *ir_analyze_instruction_unwrap_err_code(IrAnalyze *ira, |
| 11876 | 11892 | IrInstructionUnwrapErrCode *instruction) |
| 11877 | 11893 | { |
| 11878 | 11894 | IrInstruction *value = instruction->value->other; |
| 11879 | | if (value->value.type->id == TypeTableEntryIdInvalid) |
| 11895 | if (type_is_invalid(value->value.type)) |
| 11880 | 11896 | return ira->codegen->builtin_types.entry_invalid; |
| 11881 | 11897 | TypeTableEntry *ptr_type = value->value.type; |
| 11882 | 11898 | |
| ... | ... | @@ -11885,7 +11901,7 @@ static TypeTableEntry *ir_analyze_instruction_unwrap_err_code(IrAnalyze *ira, |
| 11885 | 11901 | |
| 11886 | 11902 | TypeTableEntry *non_canon_type = ptr_type->data.pointer.child_type; |
| 11887 | 11903 | TypeTableEntry *canon_type = get_underlying_type(non_canon_type); |
| 11888 | | if (canon_type->id == TypeTableEntryIdInvalid) { |
| 11904 | if (type_is_invalid(canon_type)) { |
| 11889 | 11905 | return ira->codegen->builtin_types.entry_invalid; |
| 11890 | 11906 | } else if (canon_type->id == TypeTableEntryIdErrorUnion) { |
| 11891 | 11907 | if (instr_is_comptime(value)) { |
| ... | ... | @@ -11918,7 +11934,7 @@ static TypeTableEntry *ir_analyze_instruction_unwrap_err_payload(IrAnalyze *ira, |
| 11918 | 11934 | { |
| 11919 | 11935 | assert(instruction->value->other); |
| 11920 | 11936 | IrInstruction *value = instruction->value->other; |
| 11921 | | if (value->value.type->id == TypeTableEntryIdInvalid) |
| 11937 | if (type_is_invalid(value->value.type)) |
| 11922 | 11938 | return ira->codegen->builtin_types.entry_invalid; |
| 11923 | 11939 | TypeTableEntry *ptr_type = value->value.type; |
| 11924 | 11940 | |
| ... | ... | @@ -11927,7 +11943,7 @@ static TypeTableEntry *ir_analyze_instruction_unwrap_err_payload(IrAnalyze *ira, |
| 11927 | 11943 | |
| 11928 | 11944 | TypeTableEntry *non_canon_type = ptr_type->data.pointer.child_type; |
| 11929 | 11945 | TypeTableEntry *canon_type = get_underlying_type(non_canon_type); |
| 11930 | | if (canon_type->id == TypeTableEntryIdInvalid) { |
| 11946 | if (type_is_invalid(canon_type)) { |
| 11931 | 11947 | return ira->codegen->builtin_types.entry_invalid; |
| 11932 | 11948 | } else if (canon_type->id == TypeTableEntryIdErrorUnion) { |
| 11933 | 11949 | TypeTableEntry *child_type = canon_type->data.error.child_type; |
| ... | ... | @@ -11980,13 +11996,13 @@ static TypeTableEntry *ir_analyze_instruction_fn_proto(IrAnalyze *ira, IrInstruc |
| 11980 | 11996 | FnTypeParamInfo *param_info = &fn_type_id.param_info[fn_type_id.next_param_index]; |
| 11981 | 11997 | param_info->is_noalias = param_node->data.param_decl.is_noalias; |
| 11982 | 11998 | param_info->type = ir_resolve_type(ira, param_type_value); |
| 11983 | | if (param_info->type->id == TypeTableEntryIdInvalid) |
| 11999 | if (type_is_invalid(param_info->type)) |
| 11984 | 12000 | return ira->codegen->builtin_types.entry_invalid; |
| 11985 | 12001 | } |
| 11986 | 12002 | |
| 11987 | 12003 | IrInstruction *return_type_value = instruction->return_type->other; |
| 11988 | 12004 | fn_type_id.return_type = ir_resolve_type(ira, return_type_value); |
| 11989 | | if (fn_type_id.return_type->id == TypeTableEntryIdInvalid) |
| 12005 | if (type_is_invalid(fn_type_id.return_type)) |
| 11990 | 12006 | return ira->codegen->builtin_types.entry_invalid; |
| 11991 | 12007 | |
| 11992 | 12008 | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base); |
| ... | ... | @@ -11996,7 +12012,7 @@ static TypeTableEntry *ir_analyze_instruction_fn_proto(IrAnalyze *ira, IrInstruc |
| 11996 | 12012 | |
| 11997 | 12013 | static TypeTableEntry *ir_analyze_instruction_test_comptime(IrAnalyze *ira, IrInstructionTestComptime *instruction) { |
| 11998 | 12014 | IrInstruction *value = instruction->value->other; |
| 11999 | | if (value->value.type->id == TypeTableEntryIdInvalid) |
| 12015 | if (type_is_invalid(value->value.type)) |
| 12000 | 12016 | return ira->codegen->builtin_types.entry_invalid; |
| 12001 | 12017 | |
| 12002 | 12018 | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base); |
| ... | ... | @@ -12009,7 +12025,7 @@ static TypeTableEntry *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira |
| 12009 | 12025 | { |
| 12010 | 12026 | IrInstruction *target_value = instruction->target_value->other; |
| 12011 | 12027 | TypeTableEntry *switch_type = target_value->value.type; |
| 12012 | | if (switch_type->id == TypeTableEntryIdInvalid) |
| 12028 | if (type_is_invalid(switch_type)) |
| 12013 | 12029 | return ira->codegen->builtin_types.entry_invalid; |
| 12014 | 12030 | |
| 12015 | 12031 | if (switch_type->id == TypeTableEntryIdEnumTag) { |
| ... | ... | @@ -12019,11 +12035,11 @@ static TypeTableEntry *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira |
| 12019 | 12035 | IrInstructionCheckSwitchProngsRange *range = &instruction->ranges[range_i]; |
| 12020 | 12036 | |
| 12021 | 12037 | IrInstruction *start_value = range->start->other; |
| 12022 | | if (start_value->value.type->id == TypeTableEntryIdInvalid) |
| 12038 | if (type_is_invalid(start_value->value.type)) |
| 12023 | 12039 | return ira->codegen->builtin_types.entry_invalid; |
| 12024 | 12040 | |
| 12025 | 12041 | IrInstruction *end_value = range->end->other; |
| 12026 | | if (end_value->value.type->id == TypeTableEntryIdInvalid) |
| 12042 | if (type_is_invalid(end_value->value.type)) |
| 12027 | 12043 | return ira->codegen->builtin_types.entry_invalid; |
| 12028 | 12044 | |
| 12029 | 12045 | size_t start_index; |
| ... | ... | @@ -12070,7 +12086,7 @@ static TypeTableEntry *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira |
| 12070 | 12086 | static TypeTableEntry *ir_analyze_instruction_test_type(IrAnalyze *ira, IrInstructionTestType *instruction) { |
| 12071 | 12087 | IrInstruction *type_value = instruction->type_value->other; |
| 12072 | 12088 | TypeTableEntry *type_entry = ir_resolve_type(ira, type_value); |
| 12073 | | if (type_entry->id == TypeTableEntryIdInvalid) |
| 12089 | if (type_is_invalid(type_entry)) |
| 12074 | 12090 | return ira->codegen->builtin_types.entry_invalid; |
| 12075 | 12091 | |
| 12076 | 12092 | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base); |
| ... | ... | @@ -12083,11 +12099,11 @@ static TypeTableEntry *ir_analyze_instruction_can_implicit_cast(IrAnalyze *ira, |
| 12083 | 12099 | { |
| 12084 | 12100 | IrInstruction *type_value = instruction->type_value->other; |
| 12085 | 12101 | TypeTableEntry *type_entry = ir_resolve_type(ira, type_value); |
| 12086 | | if (type_entry->id == TypeTableEntryIdInvalid) |
| 12102 | if (type_is_invalid(type_entry)) |
| 12087 | 12103 | return ira->codegen->builtin_types.entry_invalid; |
| 12088 | 12104 | |
| 12089 | 12105 | IrInstruction *target_value = instruction->target_value->other; |
| 12090 | | if (target_value->value.type->id == TypeTableEntryIdInvalid) |
| 12106 | if (type_is_invalid(target_value->value.type)) |
| 12091 | 12107 | return ira->codegen->builtin_types.entry_invalid; |
| 12092 | 12108 | |
| 12093 | 12109 | ImplicitCastMatchResult result = ir_types_match_with_implicit_cast(ira, type_entry, target_value->value.type, |