| ... | @@ -11432,6 +11432,26 @@ static TypeTableEntry *ir_analyze_bit_shift(IrAnalyze *ira, IrInstructionBinOp * | ... | @@ -11432,6 +11432,26 @@ static TypeTableEntry *ir_analyze_bit_shift(IrAnalyze *ira, IrInstructionBinOp * |
| 11432 | } else { | 11432 | } else { |
| 11433 | TypeTableEntry *shift_amt_type = get_smallest_unsigned_int_type(ira->codegen, | 11433 | TypeTableEntry *shift_amt_type = get_smallest_unsigned_int_type(ira->codegen, |
| 11434 | op1->value.type->data.integral.bit_count - 1); | 11434 | op1->value.type->data.integral.bit_count - 1); |
| | 11435 | if (bin_op_instruction->op_id == IrBinOpBitShiftLeftLossy && |
| | 11436 | op2->value.type->id == TypeTableEntryIdComptimeInt) { |
| | 11437 | if (!bigint_fits_in_bits(&op2->value.data.x_bigint, |
| | 11438 | shift_amt_type->data.integral.bit_count, |
| | 11439 | op2->value.data.x_bigint.is_negative)) { |
| | 11440 | Buf *val_buf = buf_alloc(); |
| | 11441 | bigint_append_buf(val_buf, &op2->value.data.x_bigint, 10); |
| | 11442 | ErrorMsg* msg = ir_add_error(ira, |
| | 11443 | &bin_op_instruction->base, |
| | 11444 | buf_sprintf("RHS of shift is too large for LHS type")); |
| | 11445 | add_error_note( |
| | 11446 | ira->codegen, |
| | 11447 | msg, |
| | 11448 | op2->source_node, |
| | 11449 | buf_sprintf("value %s cannot fit into type %s", |
| | 11450 | buf_ptr(val_buf), |
| | 11451 | buf_ptr(&shift_amt_type->name))); |
| | 11452 | return ira->codegen->builtin_types.entry_invalid; |
| | 11453 | } |
| | 11454 | } |
| 11435 | | 11455 | |
| 11436 | casted_op2 = ir_implicit_cast(ira, op2, shift_amt_type); | 11456 | casted_op2 = ir_implicit_cast(ira, op2, shift_amt_type); |
| 11437 | if (casted_op2 == ira->codegen->invalid_instruction) | 11457 | if (casted_op2 == ira->codegen->invalid_instruction) |