xref: /illumos-gate/usr/src/tools/smatch/src/validation/noderef.c (revision dc5e7685b131559c0b7c622baee25a9a0ae50ada)
1 # define __A	__attribute__((noderef))
2 
3 struct x {
4 	int a;
5 	int b;
6 };
7 
8 struct y {
9 	int a[2];
10 };
11 
12 static void h(void)
13 {
14 	char __A *p;
15 	char __A * * q1;
16 	char * __A * q2;
17 	struct x __A *xp;
18 	struct x __A x;
19 	int __A *q;
20 	int __A *r;
21 	struct y __A *py;
22 
23 	q1 = &p;
24 	q2 = &p;	/* This should complain */
25 
26 	r = &*q;
27 	r = q;
28 	r = &*(q+1);	/* This should NOT complain */
29 	r = q+1;
30 
31 	r = &xp->a;	/* This should NOT complain */
32 	r = &xp->b;
33 	r = &(*xp).a;
34 	r = &(*xp).b;
35 
36 	r = &x.a;
37 	r = &x.b;
38 
39 	r = py->a;
40 	r = py->a+1;
41 	r = &py->a[0];
42 }
43 /*
44  * check-name: noderef attribute
45  *
46  * check-error-start
47 noderef.c:24:12: warning: incorrect type in assignment (different modifiers)
48 noderef.c:24:12:    expected char *[noderef] *q2
49 noderef.c:24:12:    got char [noderef] **<noident>
50  * check-error-end
51  */
52