| ... | ... | @@ -987,6 +987,21 @@ static AstNode *trans_create_assign(Context *c, bool result_used, AstNode *block |
| 987 | 987 | } |
| 988 | 988 | } |
| 989 | 989 | |
| 990 | static AstNode *trans_create_shift_op(Context *c, AstNode *block, QualType result_type, Expr *lhs_expr, BinOpType bin_op, Expr *rhs_expr) { |
| 991 | const SourceLocation &rhs_location = rhs_expr->getLocStart(); |
| 992 | AstNode *rhs_type = qual_type_to_log2_int_ref(c, result_type, rhs_location); |
| 993 | // lhs >> u5(rh) |
| 994 | |
| 995 | AstNode *lhs = trans_expr(c, true, block, lhs_expr, TransLValue); |
| 996 | if (lhs == nullptr) return nullptr; |
| 997 | |
| 998 | AstNode *rhs = trans_expr(c, true, block, rhs_expr, TransRValue); |
| 999 | if (rhs == nullptr) return nullptr; |
| 1000 | AstNode *coerced_rhs = trans_create_node_fn_call_1(c, rhs_type, rhs); |
| 1001 | |
| 1002 | return trans_create_node_bin_op(c, lhs, bin_op, coerced_rhs); |
| 1003 | } |
| 1004 | |
| 990 | 1005 | static AstNode *trans_binary_operator(Context *c, bool result_used, AstNode *block, BinaryOperator *stmt) { |
| 991 | 1006 | switch (stmt->getOpcode()) { |
| 992 | 1007 | case BO_PtrMemD: |
| ... | ... | @@ -1038,11 +1053,9 @@ static AstNode *trans_binary_operator(Context *c, bool result_used, AstNode *blo |
| 1038 | 1053 | qual_type_has_wrapping_overflow(c, stmt->getType()) ? BinOpTypeSubWrap : BinOpTypeSub, |
| 1039 | 1054 | stmt->getRHS()); |
| 1040 | 1055 | case BO_Shl: |
| 1041 | | emit_warning(c, stmt->getLocStart(), "TODO handle more C binary operators: BO_Shl"); |
| 1042 | | return nullptr; |
| 1056 | return trans_create_shift_op(c, block, stmt->getType(), stmt->getLHS(), BinOpTypeBitShiftLeft, stmt->getRHS()); |
| 1043 | 1057 | case BO_Shr: |
| 1044 | | emit_warning(c, stmt->getLocStart(), "TODO handle more C binary operators: BO_Shr"); |
| 1045 | | return nullptr; |
| 1058 | return trans_create_shift_op(c, block, stmt->getType(), stmt->getLHS(), BinOpTypeBitShiftRight, stmt->getRHS()); |
| 1046 | 1059 | case BO_LT: |
| 1047 | 1060 | return trans_create_bin_op(c, block, stmt->getLHS(), BinOpTypeCmpLessThan, stmt->getRHS()); |
| 1048 | 1061 | case BO_GT: |