1*1f5207b7SJohn Levon struct ture {
2*1f5207b7SJohn Levon 	int a;
3*1f5207b7SJohn Levon };
4*1f5207b7SJohn Levon struct cont {
5*1f5207b7SJohn Levon 	struct ture *x;
6*1f5207b7SJohn Levon };
7*1f5207b7SJohn Levon 
8*1f5207b7SJohn Levon struct ture *x;
9*1f5207b7SJohn Levon struct ture **px;
10*1f5207b7SJohn Levon struct cont *y;
func(void)11*1f5207b7SJohn Levon void func (void)
12*1f5207b7SJohn Levon {
13*1f5207b7SJohn Levon 	int *a = &(x->a);
14*1f5207b7SJohn Levon 	int *b = &x->a;
15*1f5207b7SJohn Levon 	int *c = &(y->x->a);
16*1f5207b7SJohn Levon 	int *d = &((*px)->a);
17*1f5207b7SJohn Levon 
18*1f5207b7SJohn Levon 	if (x)
19*1f5207b7SJohn Levon 		frob();
20*1f5207b7SJohn Levon 	if (px)
21*1f5207b7SJohn Levon 		frob();
22*1f5207b7SJohn Levon 	if (y->x)
23*1f5207b7SJohn Levon 		frob();
24*1f5207b7SJohn Levon 	if (y)
25*1f5207b7SJohn Levon 		frob();
26*1f5207b7SJohn Levon 
27*1f5207b7SJohn Levon 	return;
28*1f5207b7SJohn Levon }
29*1f5207b7SJohn Levon /*
30*1f5207b7SJohn Levon  * check-name: Dereferencing before check
31*1f5207b7SJohn Levon  * check-command: smatch sm_deref_check_deref.c
32*1f5207b7SJohn Levon  *
33*1f5207b7SJohn Levon  * check-output-start
34*1f5207b7SJohn Levon sm_deref_check_deref.c:20 func() warn: variable dereferenced before check 'px' (see line 16)
35*1f5207b7SJohn Levon sm_deref_check_deref.c:24 func() warn: variable dereferenced before check 'y' (see line 15)
36*1f5207b7SJohn Levon  * check-output-end
37*1f5207b7SJohn Levon  */
38