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