1*c85f09ccSJohn Levon /* Resembles include/linux/compiler_types.h */
2*c85f09ccSJohn Levon #define __kernel __attribute__((address_space(0)))
3*c85f09ccSJohn Levon #define __user __attribute__((address_space(1)))
4*c85f09ccSJohn Levon #define __iomem __attribute__((address_space(2)))
5*c85f09ccSJohn Levon #define __percpu __attribute__((address_space(3)))
6*c85f09ccSJohn Levon #define __rcu __attribute__((address_space(4)))
7*c85f09ccSJohn Levon 
8*c85f09ccSJohn Levon 
9*c85f09ccSJohn Levon typedef unsigned long ulong;
10*c85f09ccSJohn Levon typedef struct s obj_t;
11*c85f09ccSJohn Levon 
expl(obj_t __kernel * k,obj_t __iomem * o,obj_t __user * p,obj_t __percpu * pc,obj_t __rcu * r)12*c85f09ccSJohn Levon static void expl(obj_t __kernel *k, obj_t __iomem *o,
13*c85f09ccSJohn Levon 		 obj_t __user *p, obj_t __percpu *pc,
14*c85f09ccSJohn Levon 		 obj_t __rcu *r)
15*c85f09ccSJohn Levon {
16*c85f09ccSJohn Levon 	(ulong)(k); (__UINTPTR_TYPE__)(k);
17*c85f09ccSJohn Levon 	(void *)(k);
18*c85f09ccSJohn Levon 	(obj_t*)(k);
19*c85f09ccSJohn Levon 	(obj_t __kernel*)(k);
20*c85f09ccSJohn Levon 
21*c85f09ccSJohn Levon 	(ulong)(o); (__UINTPTR_TYPE__)(o);
22*c85f09ccSJohn Levon 	(void *)(o);
23*c85f09ccSJohn Levon 	(obj_t*)(o);
24*c85f09ccSJohn Levon 	(obj_t __iomem*)(o);
25*c85f09ccSJohn Levon 
26*c85f09ccSJohn Levon 	(ulong)(p); (__UINTPTR_TYPE__)(p);
27*c85f09ccSJohn Levon 	(void *)(p);
28*c85f09ccSJohn Levon 	(obj_t*)(p);
29*c85f09ccSJohn Levon 	(obj_t __user*)(p);
30*c85f09ccSJohn Levon 
31*c85f09ccSJohn Levon 	(ulong)(pc); (__UINTPTR_TYPE__)(pc);
32*c85f09ccSJohn Levon 	(void *)(pc);
33*c85f09ccSJohn Levon 	(obj_t*)(pc);
34*c85f09ccSJohn Levon 	(obj_t __percpu*)(pc);
35*c85f09ccSJohn Levon 
36*c85f09ccSJohn Levon 	(ulong)(r); (__UINTPTR_TYPE__)(r);
37*c85f09ccSJohn Levon 	(void *)(r);
38*c85f09ccSJohn Levon 	(obj_t*)(r);
39*c85f09ccSJohn Levon 	(obj_t __rcu*)(r);
40*c85f09ccSJohn Levon }
41*c85f09ccSJohn Levon 
42*c85f09ccSJohn Levon /*
43*c85f09ccSJohn Levon  * check-name: Waddress-space-all-attr
44*c85f09ccSJohn Levon  * check-command: sparse -Wcast-from-as -Wcast-to-as $file
45*c85f09ccSJohn Levon  *
46*c85f09ccSJohn Levon  * check-error-start
47*c85f09ccSJohn Levon Waddress-space-all-attr.c:21:10: warning: cast removes address space '<asn:2>' of expression
48*c85f09ccSJohn Levon Waddress-space-all-attr.c:21:22: warning: cast removes address space '<asn:2>' of expression
49*c85f09ccSJohn Levon Waddress-space-all-attr.c:22:10: warning: cast removes address space '<asn:2>' of expression
50*c85f09ccSJohn Levon Waddress-space-all-attr.c:23:10: warning: cast removes address space '<asn:2>' of expression
51*c85f09ccSJohn Levon Waddress-space-all-attr.c:26:10: warning: cast removes address space '<asn:1>' of expression
52*c85f09ccSJohn Levon Waddress-space-all-attr.c:26:22: warning: cast removes address space '<asn:1>' of expression
53*c85f09ccSJohn Levon Waddress-space-all-attr.c:27:10: warning: cast removes address space '<asn:1>' of expression
54*c85f09ccSJohn Levon Waddress-space-all-attr.c:28:10: warning: cast removes address space '<asn:1>' of expression
55*c85f09ccSJohn Levon Waddress-space-all-attr.c:31:10: warning: cast removes address space '<asn:3>' of expression
56*c85f09ccSJohn Levon Waddress-space-all-attr.c:31:23: warning: cast removes address space '<asn:3>' of expression
57*c85f09ccSJohn Levon Waddress-space-all-attr.c:32:10: warning: cast removes address space '<asn:3>' of expression
58*c85f09ccSJohn Levon Waddress-space-all-attr.c:33:10: warning: cast removes address space '<asn:3>' of expression
59*c85f09ccSJohn Levon Waddress-space-all-attr.c:36:10: warning: cast removes address space '<asn:4>' of expression
60*c85f09ccSJohn Levon Waddress-space-all-attr.c:36:22: warning: cast removes address space '<asn:4>' of expression
61*c85f09ccSJohn Levon Waddress-space-all-attr.c:37:10: warning: cast removes address space '<asn:4>' of expression
62*c85f09ccSJohn Levon Waddress-space-all-attr.c:38:10: warning: cast removes address space '<asn:4>' of expression
63*c85f09ccSJohn Levon  * check-error-end
64*c85f09ccSJohn Levon  */
65