sval: type: handle type_bits() for addresses
authorDan Carpenter <dan.carpenter@oracle.com>
Mon, 19 Nov 2012 16:46:08 +0000 (19 19:46 +0300)
committerDan Carpenter <dan.carpenter@oracle.com>
Mon, 19 Nov 2012 18:47:47 +0000 (19 21:47 +0300)
Sparse doesn't set the ->bit_size field if you have an ampersand address.
So say smatch has to evaluate the expression if (&foo - &bar > 0) { ...
it wants to cast both sides to the right type but it doesn't know how.

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

index 614235c..6f71e44 100644 (file)
@@ -28,6 +28,8 @@ int type_bits(struct symbol *type)
 {
        if (!type)
                return 0;
+       if (type->type == SYM_PTR)  /* Sparse doesn't set this for &pointers */
+               return bits_in_pointer;
        return type->bit_size;
 }