1 extern int fun(void);
2 extern int arr[];
3 extern int var;
4 
test_address(int arg,int ptr[])5 int test_address(int arg, int ptr[])
6 {
7 
8 	if (fun())	return -1;
9 	if (var)	return -1;
10 	if (arg)	return -1;
11 	if (ptr)	return -1;
12 
13 lab:
14 	if (arr)	return 1;
15 	if (&arr)	return 1;
16 	if (fun)	return 1;
17 	if (&fun)	return 1;
18 	if (*fun)	return 1;
19 	if (&var)	return 1;
20 	if (&arg)	return 1;
21 	if (&&lab)	return 1;
22 
23 	return -1;
24 }
25 
test_address_not(int arg,int ptr[])26 int test_address_not(int arg, int ptr[])
27 {
28 
29 	if (!fun())	return -1;
30 	if (!var)	return -1;
31 	if (!arg)	return -1;
32 	if (!ptr)	return -1;
33 
34 lab:
35 	if (!arr)	return 0;
36 	if (!&arr)	return 0;
37 	if (!fun)	return 0;
38 	if (!&fun)	return 0;
39 	if (!*fun)	return 0;
40 	if (!&var)	return 0;
41 	if (!&arg)	return 0;
42 	if (!&&lab)	return 0;
43 
44 	return -1;
45 }
46 
test_address_cmp(int arg,int ptr[])47 int test_address_cmp(int arg, int ptr[])
48 {
49 	if (fun() == 0)	return -1;
50 	if (0 == fun())	return -1;
51 	if (var == 0)	return -1;
52 	if (0 == var)	return -1;
53 	if (arg == 0)	return -1;
54 	if (0 == arg)	return -1;
55 	if (ptr == 0)	return -1;
56 	if (0 == ptr)	return -1;
57 
58 lab:
59 	if (arr == 0)	return 0;
60 	if (0 == arr)	return 0;
61 	if (&arr == 0)	return 0;
62 	if (0 == &arr)	return 0;
63 	if (fun == 0)	return 0;
64 	if (0 == fun)	return 0;
65 	if (&fun == 0)	return 0;
66 	if (0 == &fun)	return 0;
67 	if (*fun == 0)	return 0;
68 	if (0 == *fun)	return 0;
69 	if (&var == 0)	return 0;
70 	if (0 == &var)	return 0;
71 	if (&arg == 0)	return 0;
72 	if (0 == &arg)	return 0;
73 	if (&&lab == 0)	return 0;
74 	if (0 == &&lab)	return 0;
75 
76 	return -1;
77 }
78 
79 /*
80  * check-name: Waddress
81  * check-command: sparse -Wno-decl -Wno-non-pointer-null -Waddress $file
82  * check-known-to-fail
83  *
84  * check-error-start
85 Waddress.c:14:13: warning: the address of an array will always evaluate as true
86 Waddress.c:15:14: warning: the address of an array will always evaluate as true
87 Waddress.c:16:13: warning: the address of a function will always evaluate as true
88 Waddress.c:17:14: warning: the address of a function will always evaluate as true
89 Waddress.c:18:13: warning: the address of a variable will always evaluate as true
90 Waddress.c:19:13: warning: the address of a variable will always evaluate as true
91 Waddress.c:20:13: warning: the address of a label will always evaluate as true
92 Waddress.c:34:13: warning: the address of an array will always evaluate as true
93 Waddress.c:35:13: warning: the address of an array will always evaluate as true
94 Waddress.c:36:13: warning: the address of a function will always evaluate as true
95 Waddress.c:37:13: warning: the address of a function will always evaluate as true
96 Waddress.c:38:13: warning: the address of a variable will always evaluate as true
97 Waddress.c:39:13: warning: the address of a variable will always evaluate as true
98 Waddress.c:40:13: warning: the address of a label will always evaluate as true
99 Waddress.c:57:13: warning: the address of an array will always evaluate as true
100 Waddress.c:58:13: warning: the address of an array will always evaluate as true
101 Waddress.c:59:13: warning: the address of an array will always evaluate as true
102 Waddress.c:60:13: warning: the address of an array will always evaluate as true
103 Waddress.c:61:13: warning: the address of a function will always evaluate as true
104 Waddress.c:62:13: warning: the address of a function will always evaluate as true
105 Waddress.c:63:13: warning: the address of a function will always evaluate as true
106 Waddress.c:64:13: warning: the address of a function will always evaluate as true
107 Waddress.c:65:13: warning: the address of a variable will always evaluate as true
108 Waddress.c:66:13: warning: the address of a variable will always evaluate as true
109 Waddress.c:67:13: warning: the address of a variable will always evaluate as true
110 Waddress.c:68:13: warning: the address of a variable will always evaluate as true
111 Waddress.c:69:13: warning: the address of a label will always evaluate as true
112 Waddress.c:70:13: warning: the address of a label will always evaluate as true
113  * check-error-end
114  */
115