1 void f00(void *restrict dst); 2 void f01(void *restrict *dst); 3 void f02(void *restrict *dst); 4 void f03(void *restrict *dst); 5 6 void *restrict rp; 7 void * up; 8 9 void f00(void *dst) { } /* check-should-pass */ 10 void f01(typeof(&rp) dst) { } /* check-should-pass */ 11 void f02(void **dst) { } /* check-should-fail */ 12 void f03(typeof(&up) dst) { } /* check-should-fail */ 13 14 void foo(void) 15 { 16 rp = up; /* check-should-pass */ 17 up = rp; /* check-should-pass */ 18 } 19 20 void 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 37 void 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 52 void 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 72 restrict.c:11:6: error: symbol 'f02' redeclared with different type (originally declared at restrict.c:3) - incompatible argument 1 (different modifiers) 73 restrict.c:12:6: error: symbol 'f03' redeclared with different type (originally declared at restrict.c:4) - incompatible argument 1 (different modifiers) 74 restrict.c:33:13: warning: incorrect type in assignment (different modifiers) 75 restrict.c:33:13: expected void **extern [assigned] pup 76 restrict.c:33:13: got void *const * 77 restrict.c:34:13: warning: incorrect type in assignment (different modifiers) 78 restrict.c:34:13: expected void **extern [assigned] pup 79 restrict.c:34:13: got void *const *extern [assigned] pqp 80 restrict.c:48:13: warning: incorrect type in assignment (different modifiers) 81 restrict.c:48:13: expected void **extern [assigned] pup 82 restrict.c:48:13: got void *restrict * 83 restrict.c:49:13: warning: incorrect type in assignment (different modifiers) 84 restrict.c:49:13: expected void **extern [assigned] pup 85 restrict.c:49:13: got void *restrict *extern [assigned] prp 86 restrict.c:63:13: warning: incorrect type in assignment (different modifiers) 87 restrict.c:63:13: expected void **extern [assigned] pup 88 restrict.c:63:13: got void *restrict * 89 restrict.c:64:13: warning: incorrect type in assignment (different modifiers) 90 restrict.c:64:13: expected void **extern [assigned] pup 91 restrict.c:64:13: got void *restrict *extern [assigned] prp 92 * check-error-end 93 */