| ... | ... | @@ -10121,6 +10121,30 @@ static Stage1AirInst *ir_analyze_bit_shift(IrAnalyze *ira, Stage1ZirInstBinOp *b |
| 10121 | 10121 | if (op2_val == nullptr) |
| 10122 | 10122 | return ira->codegen->invalid_inst_gen; |
| 10123 | 10123 | |
| 10124 | if (op2_val->type->id == ZigTypeIdVector) { |
| 10125 | expand_undef_array(ira->codegen, op2_val); |
| 10126 | size_t len = op2_val->type->data.vector.len; |
| 10127 | for (size_t i = 0; i < len; i += 1) { |
| 10128 | ZigValue *scalar_val = &op2_val->data.x_array.data.s_none.elements[i]; |
| 10129 | if (scalar_val->data.x_bigint.is_negative) { |
| 10130 | Buf *val_buf = buf_alloc(); |
| 10131 | bigint_append_buf(val_buf, &scalar_val->data.x_bigint, 10); |
| 10132 | ir_add_error(ira, casted_op2, |
| 10133 | buf_sprintf("shift by negative value %s at vector index %zu", |
| 10134 | buf_ptr(val_buf), i)); |
| 10135 | return ira->codegen->invalid_inst_gen; |
| 10136 | } |
| 10137 | } |
| 10138 | } else { |
| 10139 | if (op2_val->data.x_bigint.is_negative) { |
| 10140 | Buf *val_buf = buf_alloc(); |
| 10141 | bigint_append_buf(val_buf, &op2_val->data.x_bigint, 10); |
| 10142 | ir_add_error(ira, casted_op2, |
| 10143 | buf_sprintf("shift by negative value %s", buf_ptr(val_buf))); |
| 10144 | return ira->codegen->invalid_inst_gen; |
| 10145 | } |
| 10146 | } |
| 10147 | |
| 10124 | 10148 | if (value_cmp_numeric_val_all(op2_val, CmpEQ, nullptr)) |
| 10125 | 10149 | return ir_analyze_cast(ira, bin_op_instruction->base.scope, bin_op_instruction->base.source_node, op1->value->type, op1); |
| 10126 | 10150 | } |
| ... | ... | @@ -10515,14 +10539,6 @@ static Stage1AirInst *ir_analyze_bin_op_math(IrAnalyze *ira, Stage1ZirInstBinOp |
| 10515 | 10539 | return ira->codegen->invalid_inst_gen; |
| 10516 | 10540 | } |
| 10517 | 10541 | } |
| 10518 | | } else if (op_id == IrBinOpShlSat) { |
| 10519 | | if (op2_val->data.x_bigint.is_negative) { |
| 10520 | | Buf *val_buf = buf_alloc(); |
| 10521 | | bigint_append_buf(val_buf, &op2_val->data.x_bigint, 10); |
| 10522 | | ir_add_error(ira, casted_op2, |
| 10523 | | buf_sprintf("shift by negative value %s", buf_ptr(val_buf))); |
| 10524 | | return ira->codegen->invalid_inst_gen; |
| 10525 | | } |
| 10526 | 10542 | } |
| 10527 | 10543 | |
| 10528 | 10544 | return ir_analyze_math_op(ira, instruction->base.scope, instruction->base.source_node, resolved_type, op1_val, op_id, op2_val); |