| ... | @@ -16286,6 +16286,15 @@ static IrInstGen *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstSrcBinOp *bin_op_i | ... | @@ -16286,6 +16286,15 @@ static IrInstGen *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstSrcBinOp *bin_op_i |
| 16286 | IrInstGen *union_val = op1->value->type->id == ZigTypeIdUnion ? op1 : op2; | 16286 | IrInstGen *union_val = op1->value->type->id == ZigTypeIdUnion ? op1 : op2; |
| 16287 | IrInstGen *enum_val = op1->value->type->id == ZigTypeIdUnion ? op2 : op1; | 16287 | IrInstGen *enum_val = op1->value->type->id == ZigTypeIdUnion ? op2 : op1; |
| 16288 | | 16288 | |
| | 16289 | if (!is_tagged_union(union_val->value->type)) { |
| | 16290 | ErrorMsg *msg = ir_add_error_node(ira, source_node, |
| | 16291 | buf_sprintf("comparison of union and enum literal is only valid for tagged union types")); |
| | 16292 | add_error_note(ira->codegen, msg, union_val->value->type->data.unionation.decl_node, |
| | 16293 | buf_sprintf("type %s is not a tagged union", |
| | 16294 | buf_ptr(&union_val->value->type->name))); |
| | 16295 | return ira->codegen->invalid_inst_gen; |
| | 16296 | } |
| | 16297 | |
| 16289 | ZigType *tag_type = union_val->value->type->data.unionation.tag_type; | 16298 | ZigType *tag_type = union_val->value->type->data.unionation.tag_type; |
| 16290 | assert(tag_type != nullptr); | 16299 | assert(tag_type != nullptr); |
| 16291 | | 16300 | |