1 #define __bitwise       __attribute__((bitwise))
   2 #define __force         __attribute__((force))
   3 
   4 typedef unsigned int u32;
   5 typedef unsigned int __bitwise __be32;
   6 
   7 static __be32* tobi(u32 *x)
   8 {
   9         return x;                       // should warn, implicit cast
  10 }
  11 
  12 static __be32* tobe(u32 *x)
  13 {
  14         return (__be32 *) x;            // should warn, explicit cast
  15 }
  16 
  17 static __be32* tobf(u32 *x)
  18 {
  19         return (__force __be32 *) x;    // should not warn, forced cast
  20         return (__be32 __force *) x;    // should not warn, forced cast
  21 }
  22 
  23 /*
  24  * check-name: cast of bitwise pointers
  25  * check-command: sparse -Wbitwise -Wbitwise-pointer $file
  26  *
  27  * check-error-start
  28 bitwise-cast-ptr.c:9:16: warning: incorrect type in return expression (different base types)
  29 bitwise-cast-ptr.c:9:16:    expected restricted __be32 [usertype] *
  30 bitwise-cast-ptr.c:9:16:    got unsigned int [usertype] *x
  31 bitwise-cast-ptr.c:14:17: warning: cast to restricted __be32 [usertype] *
  32  * check-error-end
  33  */