1*c85f09ccSJohn Levon #define __user __attribute__((address_space(1)))
2*c85f09ccSJohn Levon 
3*c85f09ccSJohn Levon typedef unsigned long ulong;
4*c85f09ccSJohn Levon typedef struct s obj_t;
5*c85f09ccSJohn Levon 
expl(ulong u,void * v,obj_t * o,obj_t __user * p)6*c85f09ccSJohn Levon static void expl(ulong u, void *v, obj_t *o, obj_t __user *p)
7*c85f09ccSJohn Levon {
8*c85f09ccSJohn Levon 	(obj_t*)(u);
9*c85f09ccSJohn Levon 	(obj_t __user*)(u);
10*c85f09ccSJohn Levon 
11*c85f09ccSJohn Levon 	(obj_t*)(v);
12*c85f09ccSJohn Levon 	(obj_t __user*)(v);
13*c85f09ccSJohn Levon 
14*c85f09ccSJohn Levon 	(ulong)(o);
15*c85f09ccSJohn Levon 	(void *)(o);
16*c85f09ccSJohn Levon 	(obj_t*)(o);
17*c85f09ccSJohn Levon 	(obj_t __user*)(o);
18*c85f09ccSJohn Levon 
19*c85f09ccSJohn Levon 	(ulong)(p);		// w!
20*c85f09ccSJohn Levon 	(void *)(p);		// w
21*c85f09ccSJohn Levon 	(obj_t*)(p);		// w
22*c85f09ccSJohn Levon 	(obj_t __user*)(p);	// ok
23*c85f09ccSJohn Levon }
24*c85f09ccSJohn Levon 
25*c85f09ccSJohn Levon /*
26*c85f09ccSJohn Levon  * check-name: Waddress-space-strict
27*c85f09ccSJohn Levon  * check-command: sparse -Wcast-from-as -Wcast-to-as $file
28*c85f09ccSJohn Levon  *
29*c85f09ccSJohn Levon  * check-error-start
30*c85f09ccSJohn Levon Waddress-space-strict.c:12:10: warning: cast adds address space '<asn:1>' to expression
31*c85f09ccSJohn Levon Waddress-space-strict.c:17:10: warning: cast adds address space '<asn:1>' to expression
32*c85f09ccSJohn Levon Waddress-space-strict.c:19:10: warning: cast removes address space '<asn:1>' of expression
33*c85f09ccSJohn Levon Waddress-space-strict.c:20:10: warning: cast removes address space '<asn:1>' of expression
34*c85f09ccSJohn Levon Waddress-space-strict.c:21:10: warning: cast removes address space '<asn:1>' of expression
35*c85f09ccSJohn Levon  * check-error-end
36*c85f09ccSJohn Levon  */
37