aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/validation/Waddress-space-strict.c
blob: a1c5b2771e87bc05533e8d12ac8d22fe7c3d10fb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#define __user __attribute__((address_space(1)))

typedef unsigned long ulong;
typedef struct s obj_t;

static void expl(ulong u, void *v, obj_t *o, obj_t __user *p)
{
	(obj_t*)(u);
	(obj_t __user*)(u);

	(obj_t*)(v);
	(obj_t __user*)(v);

	(ulong)(o);
	(void *)(o);
	(obj_t*)(o);
	(obj_t __user*)(o);

	(ulong)(p);		// w!
	(void *)(p);		// w
	(obj_t*)(p);		// w
	(obj_t __user*)(p);	// ok
}

/*
 * check-name: Waddress-space-strict
 * check-command: sparse -Wcast-from-as -Wcast-to-as $file
 *
 * check-error-start
Waddress-space-strict.c:12:10: warning: cast adds address space '<asn:1>' to expression
Waddress-space-strict.c:17:10: warning: cast adds address space '<asn:1>' to expression
Waddress-space-strict.c:19:10: warning: cast removes address space '<asn:1>' of expression
Waddress-space-strict.c:20:10: warning: cast removes address space '<asn:1>' of expression
Waddress-space-strict.c:21:10: warning: cast removes address space '<asn:1>' of expression
 * check-error-end
 */