1void f00(void *restrict  dst);
2void f01(void *restrict *dst);
3void f02(void *restrict *dst);
4void f03(void *restrict *dst);
5
6void *restrict rp;
7void * up;
8
9void f00(void *dst)	  { }	/* check-should-pass */
10void f01(typeof(&rp) dst) { }	/* check-should-pass */
11void f02(void **dst)	  { }	/* check-should-fail */
12void f03(typeof(&up) dst) { }	/* check-should-fail */
13
14void foo(void)
15{
16	rp = up;		/* check-should-pass */
17	up = rp;		/* check-should-pass */
18}
19
20void ref(void)
21{
22	void *const qp;
23	void * up;
24	extern void *const *pqp;
25	extern void **pup;
26
27	pqp = &qp;		/* check-should-pass */
28	pqp = &up;		/* check-should-pass */
29	pqp = pup;
30
31	pup = &up;		/* check-should-pass */
32
33	pup = &qp;		/* check-should-fail */
34	pup = pqp;		/* check-should-fail */
35}
36
37void bar(void)
38{
39	extern void *restrict *prp;
40	extern void **pup;
41
42	prp = &rp;		/* check-should-pass */
43	prp = &up;		/* check-should-pass */
44	prp = pup;
45
46	pup = &up;		/* check-should-pass */
47
48	pup = &rp;		/* check-should-fail */
49	pup = prp;		/* check-should-fail */
50}
51
52void baz(void)
53{
54	extern typeof(&rp) prp;
55	extern typeof(&up) pup;
56
57	prp = &rp;		/* check-should-pass */
58	prp = &up;		/* check-should-pass */
59	prp = pup;
60
61	pup = &up;		/* check-should-pass */
62
63	pup = &rp;		/* check-should-fail */
64	pup = prp;		/* check-should-fail */
65}
66
67/*
68 * check-name: restrict qualifier
69 * check-command: sparse -Wno-decl $file;
70 *
71 * check-error-start
72restrict.c:11:6: error: symbol 'f02' redeclared with different type (originally declared at restrict.c:3) - incompatible argument 1 (different modifiers)
73restrict.c:12:6: error: symbol 'f03' redeclared with different type (originally declared at restrict.c:4) - incompatible argument 1 (different modifiers)
74restrict.c:33:13: warning: incorrect type in assignment (different modifiers)
75restrict.c:33:13:    expected void **extern [assigned] pup
76restrict.c:33:13:    got void *const *
77restrict.c:34:13: warning: incorrect type in assignment (different modifiers)
78restrict.c:34:13:    expected void **extern [assigned] pup
79restrict.c:34:13:    got void *const *extern [assigned] pqp
80restrict.c:48:13: warning: incorrect type in assignment (different modifiers)
81restrict.c:48:13:    expected void **extern [assigned] pup
82restrict.c:48:13:    got void *restrict *
83restrict.c:49:13: warning: incorrect type in assignment (different modifiers)
84restrict.c:49:13:    expected void **extern [assigned] pup
85restrict.c:49:13:    got void *restrict *extern [assigned] prp
86restrict.c:63:13: warning: incorrect type in assignment (different modifiers)
87restrict.c:63:13:    expected void **extern [assigned] pup
88restrict.c:63:13:    got void *restrict *
89restrict.c:64:13: warning: incorrect type in assignment (different modifiers)
90restrict.c:64:13:    expected void **extern [assigned] pup
91restrict.c:64:13:    got void *restrict *extern [assigned] prp
92 * check-error-end
93 */
94