type: fix get_binop_type() for bit shift operations
authorDan Carpenter <dan.carpenter@oracle.com>
Fri, 12 Oct 2012 07:58:37 +0000 (12 10:58 +0300)
committerDan Carpenter <dan.carpenter@oracle.com>
Fri, 12 Oct 2012 07:58:37 +0000 (12 10:58 +0300)
Bit shifts only depend on the left hand side.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
smatch_type.c

index 8e808a6..0214166 100644 (file)
@@ -39,6 +39,13 @@ static struct symbol *get_binop_type(struct expression *expr)
        if (right->type == SYM_PTR || right->type == SYM_ARRAY)
                return right;
 
+       if (expr->op == SPECIAL_LEFTSHIFT ||
+           expr->op == SPECIAL_RIGHTSHIFT) {
+               if (type_max(left) < type_max(&int_ctype))
+                       return &int_ctype;
+               return left;
+       }
+
        if (type_max(left) < type_max(&int_ctype) &&
            type_max(right) < type_max(&int_ctype))
                return &int_ctype;