| ... | @@ -12687,9 +12687,10 @@ static IrInstruction *ir_analyze_enum_to_union(IrAnalyze *ira, IrInstruction *so | ... | @@ -12687,9 +12687,10 @@ static IrInstruction *ir_analyze_enum_to_union(IrAnalyze *ira, IrInstruction *so |
| 12687 | ZigType *field_type = resolve_union_field_type(ira->codegen, union_field); | 12687 | ZigType *field_type = resolve_union_field_type(ira->codegen, union_field); |
| 12688 | if (field_type == nullptr) | 12688 | if (field_type == nullptr) |
| 12689 | return ira->codegen->invalid_instruction; | 12689 | return ira->codegen->invalid_instruction; |
| 12690 | if ((err = type_resolve(ira->codegen, field_type, ResolveStatusZeroBitsKnown))) | 12690 | bool has_bits; |
| | 12691 | if ((err = type_has_bits2(ira->codegen, field_type, &has_bits))) |
| 12691 | return ira->codegen->invalid_instruction; | 12692 | return ira->codegen->invalid_instruction; |
| 12692 | if (type_has_bits(field_type)) { | 12693 | if (has_bits) { |
| 12693 | AstNode *field_node = wanted_type->data.unionation.decl_node->data.container_decl.fields.at(i); | 12694 | AstNode *field_node = wanted_type->data.unionation.decl_node->data.container_decl.fields.at(i); |
| 12694 | add_error_note(ira->codegen, msg, field_node, | 12695 | add_error_note(ira->codegen, msg, field_node, |
| 12695 | buf_sprintf("field '%s' has type '%s'", | 12696 | buf_sprintf("field '%s' has type '%s'", |
| ... | @@ -13892,10 +13893,10 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst | ... | @@ -13892,10 +13893,10 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 13892 | types_match_const_cast_only(ira, wanted_type->data.pointer.child_type, | 13893 | types_match_const_cast_only(ira, wanted_type->data.pointer.child_type, |
| 13893 | actual_type, source_node, !wanted_type->data.pointer.is_const).id == ConstCastResultIdOk) | 13894 | actual_type, source_node, !wanted_type->data.pointer.is_const).id == ConstCastResultIdOk) |
| 13894 | { | 13895 | { |
| 13895 | if ((err = type_resolve(ira->codegen, actual_type, ResolveStatusZeroBitsKnown))) { | 13896 | bool has_bits; |
| | 13897 | if ((err = type_has_bits2(ira->codegen, actual_type, &has_bits))) |
| 13896 | return ira->codegen->invalid_instruction; | 13898 | return ira->codegen->invalid_instruction; |
| 13897 | } | 13899 | if (!has_bits) { |
| 13898 | if (!type_has_bits(actual_type)) { | | |
| 13899 | return ir_get_ref(ira, source_instr, value, false, false); | 13900 | return ir_get_ref(ira, source_instr, value, false, false); |
| 13900 | } | 13901 | } |
| 13901 | } | 13902 | } |
| ... | @@ -17163,10 +17164,10 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe | ... | @@ -17163,10 +17164,10 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe |
| 17163 | if (is_comptime) | 17164 | if (is_comptime) |
| 17164 | return nullptr; | 17165 | return nullptr; |
| 17165 | } | 17166 | } |
| 17166 | if ((err = type_resolve(ira->codegen, ira->explicit_return_type, ResolveStatusZeroBitsKnown))) { | 17167 | bool has_bits; |
| | 17168 | if ((err = type_has_bits2(ira->codegen, ira->explicit_return_type, &has_bits))) |
| 17167 | return ira->codegen->invalid_instruction; | 17169 | return ira->codegen->invalid_instruction; |
| 17168 | } | 17170 | if (!has_bits || !handle_is_ptr(ira->explicit_return_type)) { |
| 17169 | if (!type_has_bits(ira->explicit_return_type) || !handle_is_ptr(ira->explicit_return_type)) { | | |
| 17170 | ZigFn *fn_entry = exec_fn_entry(ira->new_irb.exec); | 17171 | ZigFn *fn_entry = exec_fn_entry(ira->new_irb.exec); |
| 17171 | if (fn_entry == nullptr || fn_entry->inferred_async_node == nullptr) { | 17172 | if (fn_entry == nullptr || fn_entry->inferred_async_node == nullptr) { |
| 17172 | return nullptr; | 17173 | return nullptr; |
| ... | @@ -26082,6 +26083,7 @@ static IrInstruction *ir_analyze_unwrap_error_payload(IrAnalyze *ira, IrInstruct | ... | @@ -26082,6 +26083,7 @@ static IrInstruction *ir_analyze_unwrap_error_payload(IrAnalyze *ira, IrInstruct |
| 26082 | ZigType *result_type = get_pointer_to_type_extra(ira->codegen, payload_type, | 26083 | ZigType *result_type = get_pointer_to_type_extra(ira->codegen, payload_type, |
| 26083 | ptr_type->data.pointer.is_const, ptr_type->data.pointer.is_volatile, | 26084 | ptr_type->data.pointer.is_const, ptr_type->data.pointer.is_volatile, |
| 26084 | PtrLenSingle, 0, 0, 0, false); | 26085 | PtrLenSingle, 0, 0, 0, false); |
| | 26086 | |
| 26085 | if (instr_is_comptime(base_ptr)) { | 26087 | if (instr_is_comptime(base_ptr)) { |
| 26086 | ZigValue *ptr_val = ir_resolve_const(ira, base_ptr, UndefBad); | 26088 | ZigValue *ptr_val = ir_resolve_const(ira, base_ptr, UndefBad); |
| 26087 | if (!ptr_val) | 26089 | if (!ptr_val) |
| ... | @@ -27136,15 +27138,16 @@ static IrInstruction *ir_analyze_instruction_int_to_ptr(IrAnalyze *ira, IrInstru | ... | @@ -27136,15 +27138,16 @@ static IrInstruction *ir_analyze_instruction_int_to_ptr(IrAnalyze *ira, IrInstru |
| 27136 | return ira->codegen->invalid_instruction; | 27138 | return ira->codegen->invalid_instruction; |
| 27137 | } | 27139 | } |
| 27138 | | 27140 | |
| 27139 | if ((err = type_resolve(ira->codegen, dest_type, ResolveStatusZeroBitsKnown))) | 27141 | bool has_bits; |
| | 27142 | if ((err = type_has_bits2(ira->codegen, dest_type, &has_bits))) |
| 27140 | return ira->codegen->invalid_instruction; | 27143 | return ira->codegen->invalid_instruction; |
| 27141 | if (!type_has_bits(dest_type)) { | 27144 | |
| | 27145 | if (!has_bits) { |
| 27142 | ir_add_error(ira, dest_type_value, | 27146 | ir_add_error(ira, dest_type_value, |
| 27143 | buf_sprintf("type '%s' has 0 bits and cannot store information", buf_ptr(&dest_type->name))); | 27147 | buf_sprintf("type '%s' has 0 bits and cannot store information", buf_ptr(&dest_type->name))); |
| 27144 | return ira->codegen->invalid_instruction; | 27148 | return ira->codegen->invalid_instruction; |
| 27145 | } | 27149 | } |
| 27146 | | 27150 | |
| 27147 | | | |
| 27148 | IrInstruction *target = instruction->target->child; | 27151 | IrInstruction *target = instruction->target->child; |
| 27149 | if (type_is_invalid(target->value->type)) | 27152 | if (type_is_invalid(target->value->type)) |
| 27150 | return ira->codegen->invalid_instruction; | 27153 | return ira->codegen->invalid_instruction; |
| ... | @@ -27182,9 +27185,11 @@ static IrInstruction *ir_analyze_instruction_ptr_to_int(IrAnalyze *ira, IrInstru | ... | @@ -27182,9 +27185,11 @@ static IrInstruction *ir_analyze_instruction_ptr_to_int(IrAnalyze *ira, IrInstru |
| 27182 | return ira->codegen->invalid_instruction; | 27185 | return ira->codegen->invalid_instruction; |
| 27183 | } | 27186 | } |
| 27184 | | 27187 | |
| 27185 | if ((err = type_resolve(ira->codegen, target->value->type, ResolveStatusZeroBitsKnown))) | 27188 | bool has_bits; |
| | 27189 | if ((err = type_has_bits2(ira->codegen, target->value->type, &has_bits))) |
| 27186 | return ira->codegen->invalid_instruction; | 27190 | return ira->codegen->invalid_instruction; |
| 27187 | if (!type_has_bits(target->value->type)) { | 27191 | |
| | 27192 | if (!has_bits) { |
| 27188 | ir_add_error(ira, target, | 27193 | ir_add_error(ira, target, |
| 27189 | buf_sprintf("pointer to size 0 type has no address")); | 27194 | buf_sprintf("pointer to size 0 type has no address")); |
| 27190 | return ira->codegen->invalid_instruction; | 27195 | return ira->codegen->invalid_instruction; |
| ... | @@ -29067,9 +29072,10 @@ static ZigType *ir_resolve_lazy_fn_type(IrAnalyze *ira, AstNode *source_node, La | ... | @@ -29067,9 +29072,10 @@ static ZigType *ir_resolve_lazy_fn_type(IrAnalyze *ira, AstNode *source_node, La |
| 29067 | break; | 29072 | break; |
| 29068 | } | 29073 | } |
| 29069 | if (!calling_convention_allows_zig_types(fn_type_id.cc)) { | 29074 | if (!calling_convention_allows_zig_types(fn_type_id.cc)) { |
| 29070 | if ((err = type_resolve(ira->codegen, param_type, ResolveStatusZeroBitsKnown))) | 29075 | bool has_bits; |
| | 29076 | if ((err = type_has_bits2(ira->codegen, param_type, &has_bits))) |
| 29071 | return nullptr; | 29077 | return nullptr; |
| 29072 | if (!type_has_bits(param_type)) { | 29078 | if (!has_bits) { |
| 29073 | ir_add_error(ira, param_type_inst, | 29079 | ir_add_error(ira, param_type_inst, |
| 29074 | buf_sprintf("parameter of type '%s' has 0 bits; not allowed in function with calling convention '%s'", | 29080 | buf_sprintf("parameter of type '%s' has 0 bits; not allowed in function with calling convention '%s'", |
| 29075 | buf_ptr(&param_type->name), calling_convention_name(fn_type_id.cc))); | 29081 | buf_ptr(&param_type->name), calling_convention_name(fn_type_id.cc))); |