Fix ICE in substring-handling building 502.gcc_r (PR 87562)
[official-gcc.git] / gcc / testsuite / gcc.dg / Wsizeof-pointer-memaccess1.c
blob4d14de28b10a250a231fc0c9ed93e33de5bad54e
1 /* Test -Wsizeof-pointer-memaccess warnings. */
2 /* { dg-do compile } */
3 /* { dg-options "-Wall -Wno-array-bounds -Wno-sizeof-array-argument -Wno-stringop-overflow" } */
4 /* { dg-require-effective-target alloca } */
6 typedef __SIZE_TYPE__ size_t;
7 extern void bzero (void *, size_t);
8 extern void bcopy (void *, const void *, size_t);
9 extern int bcmp (const void *, const void *, size_t);
11 struct A { short a, b; int c, d; long e, f; };
12 typedef struct A TA;
13 typedef struct A *PA;
14 typedef TA *PTA;
15 struct B {};
16 typedef struct B TB;
17 typedef struct B *PB;
18 typedef TB *PTB;
19 typedef int X[3][3][3];
21 int
22 f1 (void *x, int z)
24 struct A a, *pa1 = &a;
25 TA *pa2 = &a;
26 PA pa3 = &a;
27 PTA pa4 = &a;
28 bzero (&a, sizeof (&a)); /* { dg-warning "call is the same expression as the destination; did you mean to remove the addressof" } */
29 bzero (pa1, sizeof (pa1)); /* { dg-warning "call is the same expression as the destination; did you mean to dereference it" } */
30 bzero (pa2, sizeof pa2); /* { dg-warning "call is the same expression as the destination; did you mean to dereference it" } */
31 bzero (pa3, sizeof (pa3)); /* { dg-warning "call is the same expression as the destination; did you mean to dereference it" } */
32 bzero (pa4, sizeof pa4); /* { dg-warning "call is the same expression as the destination; did you mean to dereference it" } */
33 bzero (pa1, sizeof (struct A *)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" } */
34 bzero (pa2, sizeof (PTA)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" } */
35 bzero (pa3, sizeof (PA)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" } */
36 bzero (pa4, sizeof (__typeof (pa4))); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" } */
38 bcopy (x, &a, sizeof (&a)); /* { dg-warning "call is the same expression as the destination; did you mean to remove the addressof" } */
39 bcopy (x, pa1, sizeof (pa1)); /* { dg-warning "call is the same expression as the destination; did you mean to dereference it" } */
40 bcopy (x, pa2, sizeof pa2); /* { dg-warning "call is the same expression as the destination; did you mean to dereference it" } */
41 bcopy (x, pa3, sizeof (pa3)); /* { dg-warning "call is the same expression as the destination; did you mean to dereference it" } */
42 bcopy (x, pa4, sizeof pa4); /* { dg-warning "call is the same expression as the destination; did you mean to dereference it" } */
43 bcopy (x, pa1, sizeof (struct A *)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" } */
44 bcopy (x, pa2, sizeof (PTA)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" } */
45 bcopy (x, pa3, sizeof (PA)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" } */
46 bcopy (x, pa4, sizeof (__typeof (pa4))); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" } */
48 bcopy (&a, x, sizeof (&a)); /* { dg-warning "call is the same expression as the source; did you mean to remove the addressof" } */
49 bcopy (pa1, x, sizeof (pa1)); /* { dg-warning "call is the same expression as the source; did you mean to dereference it" } */
50 bcopy (pa2, x, sizeof pa2); /* { dg-warning "call is the same expression as the source; did you mean to dereference it" } */
51 bcopy (pa3, x, sizeof (pa3)); /* { dg-warning "call is the same expression as the source; did you mean to dereference it" } */
52 bcopy (pa4, x, sizeof pa4); /* { dg-warning "call is the same expression as the source; did you mean to dereference it" } */
53 bcopy (pa1, x, sizeof (struct A *)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the source; expected \[^\n\r\]* or an explicit length" } */
54 bcopy (pa2, x, sizeof (PTA)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the source; expected \[^\n\r\]* or an explicit length" } */
55 bcopy (pa3, x, sizeof (PA)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the source; expected \[^\n\r\]* or an explicit length" } */
56 bcopy (pa4, x, sizeof (__typeof (pa4))); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the source; expected \[^\n\r\]* or an explicit length" } */
58 z += bcmp (&a, x, sizeof (&a)); /* { dg-warning "call is the same expression as the first source; did you mean to remove the addressof" } */
59 z += bcmp (pa1, x, sizeof (pa1)); /* { dg-warning "call is the same expression as the first source; did you mean to dereference it" } */
60 z += bcmp (pa2, x, sizeof pa2); /* { dg-warning "call is the same expression as the first source; did you mean to dereference it" } */
61 z += bcmp (pa3, x, sizeof (pa3)); /* { dg-warning "call is the same expression as the first source; did you mean to dereference it" } */
62 z += bcmp (pa4, x, sizeof pa4); /* { dg-warning "call is the same expression as the first source; did you mean to dereference it" } */
63 z += bcmp (pa1, x, sizeof (struct A *)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the first source; expected \[^\n\r\]* or an explicit length" } */
64 z += bcmp (pa2, x, sizeof (PTA)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the first source; expected \[^\n\r\]* or an explicit length" } */
65 z += bcmp (pa3, x, sizeof (PA)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the first source; expected \[^\n\r\]* or an explicit length" } */
67 z += bcmp (x, &a, sizeof (&a)); /* { dg-warning "call is the same expression as the second source; did you mean to remove the addressof" } */
68 z += bcmp (x, pa1, sizeof (pa1)); /* { dg-warning "call is the same expression as the second source; did you mean to dereference it" } */
69 z += bcmp (x, pa2, sizeof pa2); /* { dg-warning "call is the same expression as the second source; did you mean to dereference it" } */
70 z += bcmp (x, pa3, sizeof (pa3)); /* { dg-warning "call is the same expression as the second source; did you mean to dereference it" } */
71 z += bcmp (x, pa4, sizeof pa4); /* { dg-warning "call is the same expression as the second source; did you mean to dereference it" } */
72 z += bcmp (x, pa1, sizeof (struct A *)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the second source; expected \[^\n\r\]* or an explicit length" } */
73 z += bcmp (x, pa2, sizeof (PTA)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the second source; expected \[^\n\r\]* or an explicit length" } */
74 z += bcmp (x, pa3, sizeof (PA)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the second source; expected \[^\n\r\]* or an explicit length" } */
76 z += bcmp (x, (&a), (sizeof (&a))); /* { dg-warning "call is the same expression as the second source; did you mean to remove the addressof" } */
77 z += bcmp (x, (pa1), (sizeof (pa1))); /* { dg-warning "call is the same expression as the second source; did you mean to dereference it" } */
78 z += bcmp (x, (pa2), (sizeof pa2)); /* { dg-warning "call is the same expression as the second source; did you mean to dereference it" } */
79 z += bcmp (x, (pa3), (sizeof (pa3))); /* { dg-warning "call is the same expression as the second source; did you mean to dereference it" } */
80 z += bcmp (x, (pa4), (sizeof pa4)); /* { dg-warning "call is the same expression as the second source; did you mean to dereference it" } */
81 z += bcmp (x, (pa1), (sizeof (struct A *)));/* { dg-warning "call is the same pointer type \[^\n\r\]* as the second source; expected \[^\n\r\]* or an explicit length" } */
82 z += bcmp (x, (pa2), (sizeof (PTA))); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the second source; expected \[^\n\r\]* or an explicit length" } */
83 z += bcmp (x, (pa3), (sizeof (PA))); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the second source; expected \[^\n\r\]* or an explicit length" } */
85 /* These are correct, no warning. */
86 bzero (&a, sizeof a);
87 bzero (&a, sizeof (a));
88 bzero (&a, sizeof (struct A));
89 bzero (&a, sizeof (const struct A));
90 bzero (&a, sizeof (volatile struct A));
91 bzero (&a, sizeof (volatile const struct A));
92 bzero (&a, sizeof (TA));
93 bzero (&a, sizeof (__typeof (*&a)));
94 bzero (pa1, sizeof (*pa1));
95 bzero (pa2, sizeof (*pa3));
96 bzero (pa3, sizeof (__typeof (*pa3)));
97 /* These are probably broken, but obfuscated, no warning. */
98 bzero ((void *) &a, sizeof (&a));
99 bzero ((char *) &a, sizeof (&a));
100 bzero (&a, sizeof (&a) + 0);
101 bzero (&a, 0 + sizeof (&a));
103 /* These are correct, no warning. */
104 bcopy (x, &a, sizeof a);
105 bcopy (x, &a, sizeof (a));
106 bcopy (x, &a, sizeof (struct A));
107 bcopy (x, &a, sizeof (const struct A));
108 bcopy (x, &a, sizeof (volatile struct A));
109 bcopy (x, &a, sizeof (volatile const struct A));
110 bcopy (x, &a, sizeof (TA));
111 bcopy (x, &a, sizeof (__typeof (*&a)));
112 bcopy (x, pa1, sizeof (*pa1));
113 bcopy (x, pa2, sizeof (*pa3));
114 bcopy (x, pa3, sizeof (__typeof (*pa3)));
115 /* These are probably broken, but obfuscated, no warning. */
116 bcopy (x, (void *) &a, sizeof (&a));
117 bcopy (x, (char *) &a, sizeof (&a));
118 bcopy (x, &a, sizeof (&a) + 0);
119 bcopy (x, &a, 0 + sizeof (&a));
121 /* These are correct, no warning. */
122 bcopy (&a, x, sizeof a);
123 bcopy (&a, x, sizeof (a));
124 bcopy (&a, x, sizeof (struct A));
125 bcopy (&a, x, sizeof (const struct A));
126 bcopy (&a, x, sizeof (volatile struct A));
127 bcopy (&a, x, sizeof (volatile const struct A));
128 bcopy (&a, x, sizeof (TA));
129 bcopy (&a, x, sizeof (__typeof (*&a)));
130 bcopy (pa1, x, sizeof (*pa1));
131 bcopy (pa2, x, sizeof (*pa3));
132 bcopy (pa3, x, sizeof (__typeof (*pa3)));
133 /* These are probably broken, but obfuscated, no warning. */
134 bcopy ((void *) &a, x, sizeof (&a));
135 bcopy ((char *) &a, x, sizeof (&a));
136 bcopy (&a, x, sizeof (&a) + 0);
137 bcopy (&a, x, 0 + sizeof (&a));
139 /* These are correct, no warning. */
140 z += bcmp (&a, x, sizeof a);
141 z += bcmp (&a, x, sizeof (a));
142 z += bcmp (&a, x, sizeof (struct A));
143 z += bcmp (&a, x, sizeof (const struct A));
144 z += bcmp (&a, x, sizeof (volatile struct A));
145 z += bcmp (&a, x, sizeof (volatile const struct A));
146 z += bcmp (&a, x, sizeof (TA));
147 z += bcmp (&a, x, sizeof (__typeof (*&a)));
148 z += bcmp (pa1, x, sizeof (*pa1));
149 z += bcmp (pa2, x, sizeof (*pa3));
150 z += bcmp (pa3, x, sizeof (__typeof (*pa3)));
151 /* These are probably broken, but obfuscated, no warning. */
152 z += bcmp ((void *) &a, x, sizeof (&a));
153 z += bcmp ((char *) &a, x, sizeof (&a));
154 z += bcmp (&a, x, sizeof (&a) + 0);
155 z += bcmp (&a, x, 0 + sizeof (&a));
157 /* These are correct, no warning. */
158 z += bcmp (x, &a, sizeof a);
159 z += bcmp (x, &a, sizeof (a));
160 z += bcmp (x, &a, sizeof (struct A));
161 z += bcmp (x, &a, sizeof (const struct A));
162 z += bcmp (x, &a, sizeof (volatile struct A));
163 z += bcmp (x, &a, sizeof (volatile const struct A));
164 z += bcmp (x, &a, sizeof (TA));
165 z += bcmp (x, &a, sizeof (__typeof (*&a)));
166 z += bcmp (x, pa1, sizeof (*pa1));
167 z += bcmp (x, pa2, sizeof (*pa3));
168 z += bcmp (x, pa3, sizeof (__typeof (*pa3)));
169 /* These are probably broken, but obfuscated, no warning. */
170 z += bcmp (x, (void *) &a, sizeof (&a));
171 z += bcmp (x, (char *) &a, sizeof (&a));
172 z += bcmp (x, &a, sizeof (&a) + 0);
173 z += bcmp (x, &a, 0 + sizeof (&a));
175 return z;
179 f2 (void *x, int z)
181 struct B b, *pb1 = &b;
182 TB *pb2 = &b;
183 PB pb3 = &b;
184 PTB pb4 = &b;
185 bzero (&b, sizeof (&b)); /* { dg-warning "call is the same expression as the destination; did you mean to remove the addressof" } */
186 bzero (pb1, sizeof (pb1)); /* { dg-warning "call is the same expression as the destination; did you mean to dereference it" } */
187 bzero (pb2, sizeof pb2); /* { dg-warning "call is the same expression as the destination; did you mean to dereference it" } */
188 bzero (pb3, sizeof (pb3)); /* { dg-warning "call is the same expression as the destination; did you mean to dereference it" } */
189 bzero (pb4, sizeof pb4); /* { dg-warning "call is the same expression as the destination; did you mean to dereference it" } */
190 bzero (pb1, sizeof (struct B *)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" } */
191 bzero (pb2, sizeof (PTB)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" } */
192 bzero (pb3, sizeof (PB)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" } */
193 bzero (pb4, sizeof (__typeof (pb4))); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" } */
195 bcopy (x, &b, sizeof (&b)); /* { dg-warning "call is the same expression as the destination; did you mean to remove the addressof" } */
196 bcopy (x, pb1, sizeof (pb1)); /* { dg-warning "call is the same expression as the destination; did you mean to dereference it" } */
197 bcopy (x, pb2, sizeof pb2); /* { dg-warning "call is the same expression as the destination; did you mean to dereference it" } */
198 bcopy (x, pb3, sizeof (pb3)); /* { dg-warning "call is the same expression as the destination; did you mean to dereference it" } */
199 bcopy (x, pb4, sizeof pb4); /* { dg-warning "call is the same expression as the destination; did you mean to dereference it" } */
200 bcopy (x, pb1, sizeof (struct B *)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" } */
201 bcopy (x, pb2, sizeof (PTB)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" } */
202 bcopy (x, pb3, sizeof (PB)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" } */
203 bcopy (x, pb4, sizeof (__typeof (pb4))); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" } */
205 bcopy (&b, x, sizeof (&b)); /* { dg-warning "call is the same expression as the source; did you mean to remove the addressof" } */
206 bcopy (pb1, x, sizeof (pb1)); /* { dg-warning "call is the same expression as the source; did you mean to dereference it" } */
207 bcopy (pb2, x, sizeof pb2); /* { dg-warning "call is the same expression as the source; did you mean to dereference it" } */
208 bcopy (pb3, x, sizeof (pb3)); /* { dg-warning "call is the same expression as the source; did you mean to dereference it" } */
209 bcopy (pb4, x, sizeof pb4); /* { dg-warning "call is the same expression as the source; did you mean to dereference it" } */
210 bcopy (pb1, x, sizeof (struct B *)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the source; expected \[^\n\r\]* or an explicit length" } */
211 bcopy (pb2, x, sizeof (PTB)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the source; expected \[^\n\r\]* or an explicit length" } */
212 bcopy (pb3, x, sizeof (PB)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the source; expected \[^\n\r\]* or an explicit length" } */
213 bcopy (pb4, x, sizeof (__typeof (pb4))); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the source; expected \[^\n\r\]* or an explicit length" } */
215 z += bcmp (&b, x, sizeof (&b)); /* { dg-warning "call is the same expression as the first source; did you mean to remove the addressof" } */
216 z += bcmp (pb1, x, sizeof (pb1)); /* { dg-warning "call is the same expression as the first source; did you mean to dereference it" } */
217 z += bcmp (pb2, x, sizeof pb2); /* { dg-warning "call is the same expression as the first source; did you mean to dereference it" } */
218 z += bcmp (pb3, x, sizeof (pb3)); /* { dg-warning "call is the same expression as the first source; did you mean to dereference it" } */
219 z += bcmp (pb4, x, sizeof pb4); /* { dg-warning "call is the same expression as the first source; did you mean to dereference it" } */
220 z += bcmp (pb1, x, sizeof (struct B *)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the first source; expected \[^\n\r\]* or an explicit length" } */
221 z += bcmp (pb2, x, sizeof (PTB)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the first source; expected \[^\n\r\]* or an explicit length" } */
222 z += bcmp (pb3, x, sizeof (PB)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the first source; expected \[^\n\r\]* or an explicit length" } */
224 z += bcmp (x, &b, sizeof (&b)); /* { dg-warning "call is the same expression as the second source; did you mean to remove the addressof" } */
225 z += bcmp (x, pb1, sizeof (pb1)); /* { dg-warning "call is the same expression as the second source; did you mean to dereference it" } */
226 z += bcmp (x, pb2, sizeof pb2); /* { dg-warning "call is the same expression as the second source; did you mean to dereference it" } */
227 z += bcmp (x, pb3, sizeof (pb3)); /* { dg-warning "call is the same expression as the second source; did you mean to dereference it" } */
228 z += bcmp (x, pb4, sizeof pb4); /* { dg-warning "call is the same expression as the second source; did you mean to dereference it" } */
229 z += bcmp (x, pb1, sizeof (struct B *)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the second source; expected \[^\n\r\]* or an explicit length" } */
230 z += bcmp (x, pb2, sizeof (PTB)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the second source; expected \[^\n\r\]* or an explicit length" } */
231 z += bcmp (x, pb3, sizeof (PB)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the second source; expected \[^\n\r\]* or an explicit length" } */
233 /* These are correct, no warning. */
234 bzero (&b, sizeof b);
235 bzero (&b, sizeof (b));
236 bzero (&b, sizeof (struct B));
237 bzero (&b, sizeof (const struct B));
238 bzero (&b, sizeof (volatile struct B));
239 bzero (&b, sizeof (volatile const struct B));
240 bzero (&b, sizeof (TB));
241 bzero (&b, sizeof (__typeof (*&b)));
242 bzero (pb1, sizeof (*pb1));
243 bzero (pb2, sizeof (*pb3));
244 bzero (pb3, sizeof (__typeof (*pb3)));
245 /* These are probably broken, but obfuscated, no warning. */
246 bzero ((void *) &b, sizeof (&b));
247 bzero ((char *) &b, sizeof (&b));
248 bzero (&b, sizeof (&b) + 0);
249 bzero (&b, 0 + sizeof (&b));
251 /* These are correct, no warning. */
252 bcopy (x, &b, sizeof b);
253 bcopy (x, &b, sizeof (b));
254 bcopy (x, &b, sizeof (struct B));
255 bcopy (x, &b, sizeof (const struct B));
256 bcopy (x, &b, sizeof (volatile struct B));
257 bcopy (x, &b, sizeof (volatile const struct B));
258 bcopy (x, &b, sizeof (TB));
259 bcopy (x, &b, sizeof (__typeof (*&b)));
260 bcopy (x, pb1, sizeof (*pb1));
261 bcopy (x, pb2, sizeof (*pb3));
262 bcopy (x, pb3, sizeof (__typeof (*pb3)));
263 /* These are probably broken, but obfuscated, no warning. */
264 bcopy (x, (void *) &b, sizeof (&b));
265 bcopy (x, (char *) &b, sizeof (&b));
266 bcopy (x, &b, sizeof (&b) + 0);
267 bcopy (x, &b, 0 + sizeof (&b));
269 /* These are correct, no warning. */
270 bcopy (&b, x, sizeof b);
271 bcopy (&b, x, sizeof (b));
272 bcopy (&b, x, sizeof (struct B));
273 bcopy (&b, x, sizeof (const struct B));
274 bcopy (&b, x, sizeof (volatile struct B));
275 bcopy (&b, x, sizeof (volatile const struct B));
276 bcopy (&b, x, sizeof (TB));
277 bcopy (&b, x, sizeof (__typeof (*&b)));
278 bcopy (pb1, x, sizeof (*pb1));
279 bcopy (pb2, x, sizeof (*pb3));
280 bcopy (pb3, x, sizeof (__typeof (*pb3)));
281 /* These are probably broken, but obfuscated, no warning. */
282 bcopy ((void *) &b, x, sizeof (&b));
283 bcopy ((char *) &b, x, sizeof (&b));
284 bcopy (&b, x, sizeof (&b) + 0);
285 bcopy (&b, x, 0 + sizeof (&b));
287 /* These are correct, no warning. */
288 z += bcmp (&b, x, sizeof b);
289 z += bcmp (&b, x, sizeof (b));
290 z += bcmp (&b, x, sizeof (struct B));
291 z += bcmp (&b, x, sizeof (const struct B));
292 z += bcmp (&b, x, sizeof (volatile struct B));
293 z += bcmp (&b, x, sizeof (volatile const struct B));
294 z += bcmp (&b, x, sizeof (TB));
295 z += bcmp (&b, x, sizeof (__typeof (*&b)));
296 z += bcmp (pb1, x, sizeof (*pb1));
297 z += bcmp (pb2, x, sizeof (*pb3));
298 z += bcmp (pb3, x, sizeof (__typeof (*pb3)));
299 /* These are probably broken, but obfuscated, no warning. */
300 z += bcmp ((void *) &b, x, sizeof (&b));
301 z += bcmp ((char *) &b, x, sizeof (&b));
302 z += bcmp (&b, x, sizeof (&b) + 0);
303 z += bcmp (&b, x, 0 + sizeof (&b));
305 /* These are correct, no warning. */
306 z += bcmp (x, &b, sizeof b);
307 z += bcmp (x, &b, sizeof (b));
308 z += bcmp (x, &b, sizeof (struct B));
309 z += bcmp (x, &b, sizeof (const struct B));
310 z += bcmp (x, &b, sizeof (volatile struct B));
311 z += bcmp (x, &b, sizeof (volatile const struct B));
312 z += bcmp (x, &b, sizeof (TB));
313 z += bcmp (x, &b, sizeof (__typeof (*&b)));
314 z += bcmp (x, pb1, sizeof (*pb1));
315 z += bcmp (x, pb2, sizeof (*pb3));
316 z += bcmp (x, pb3, sizeof (__typeof (*pb3)));
317 /* These are probably broken, but obfuscated, no warning. */
318 z += bcmp (x, (void *) &b, sizeof (&b));
319 z += bcmp (x, (char *) &b, sizeof (&b));
320 z += bcmp (x, &b, sizeof (&b) + 0);
321 z += bcmp (x, &b, 0 + sizeof (&b));
323 return z;
327 f3 (void *x, char *y, int z, X w)
329 unsigned char *y1 = (unsigned char *) __builtin_alloca (z + 16);
330 char buf1[7];
331 signed char buf2[z + 32];
332 long buf3[17];
333 int *buf4[9];
334 signed char *y2 = buf2;
335 char c;
336 char *y3;
337 bzero (y, sizeof (y)); /* { dg-warning "call is the same expression as the destination; did you mean to provide an explicit length" } */
338 bzero (y1, sizeof (y1)); /* { dg-warning "call is the same expression as the destination; did you mean to provide an explicit length" } */
339 bzero (y2, sizeof (y2)); /* { dg-warning "call is the same expression as the destination; did you mean to provide an explicit length" } */
340 bzero (&c, sizeof (&c)); /* { dg-warning "call is the same expression as the destination; did you mean to remove the addressof" } */
341 bzero (w, sizeof w); /* { dg-warning "call is the same expression as the destination; did you mean to dereference it" } */
343 bcopy (x, y, sizeof (y)); /* { dg-warning "call is the same expression as the destination; did you mean to provide an explicit length" } */
344 bcopy (x, y1, sizeof (y1)); /* { dg-warning "call is the same expression as the destination; did you mean to provide an explicit length" } */
345 bcopy (x, y2, sizeof (y2)); /* { dg-warning "call is the same expression as the destination; did you mean to provide an explicit length" } */
346 bcopy (x, &c, sizeof (&c)); /* { dg-warning "call is the same expression as the destination; did you mean to remove the addressof" } */
347 bcopy (x, w, sizeof w); /* { dg-warning "call is the same expression as the destination; did you mean to dereference it" } */
349 bcopy (y, x, sizeof (y)); /* { dg-warning "call is the same expression as the source; did you mean to provide an explicit length" } */
350 bcopy (y1, x, sizeof (y1)); /* { dg-warning "call is the same expression as the source; did you mean to provide an explicit length" } */
351 bcopy (y2, x, sizeof (y2)); /* { dg-warning "call is the same expression as the source; did you mean to provide an explicit length" } */
352 bcopy (&c, x, sizeof (&c)); /* { dg-warning "call is the same expression as the source; did you mean to remove the addressof" } */
353 bcopy (w, x, sizeof w); /* { dg-warning "call is the same expression as the source; did you mean to dereference it" } */
355 z += bcmp (y, x, sizeof (y)); /* { dg-warning "call is the same expression as the first source; did you mean to provide an explicit length" } */
356 z += bcmp (y1, x, sizeof (y1)); /* { dg-warning "call is the same expression as the first source; did you mean to provide an explicit length" } */
357 z += bcmp (y2, x, sizeof (y2)); /* { dg-warning "call is the same expression as the first source; did you mean to provide an explicit length" } */
358 z += bcmp (&c, x, sizeof (&c)); /* { dg-warning "call is the same expression as the first source; did you mean to remove the addressof" } */
359 z += bcmp (w, x, sizeof w); /* { dg-warning "call is the same expression as the first source; did you mean to dereference it" } */
361 z += bcmp (x, y, sizeof (y)); /* { dg-warning "call is the same expression as the second source; did you mean to provide an explicit length" } */
362 z += bcmp (x, y1, sizeof (y1)); /* { dg-warning "call is the same expression as the second source; did you mean to provide an explicit length" } */
363 z += bcmp (x, y2, sizeof (y2)); /* { dg-warning "call is the same expression as the second source; did you mean to provide an explicit length" } */
364 z += bcmp (x, &c, sizeof (&c)); /* { dg-warning "call is the same expression as the second source; did you mean to remove the addressof" } */
365 z += bcmp (x, w, sizeof w); /* { dg-warning "call is the same expression as the second source; did you mean to dereference it" } */
367 /* These are correct, no warning. */
368 bzero (y, sizeof (*y));
369 bzero (y1, sizeof (*y2));
370 bzero (buf1, sizeof buf1);
371 bzero (buf3, sizeof (buf3));
372 bzero (&buf3[0], sizeof (buf3));
373 bzero (&buf4[0], sizeof (buf4));
374 bzero (w, sizeof (X));
375 /* These are probably broken, but obfuscated, no warning. */
376 bzero ((void *) y, sizeof (y));
377 bzero ((char *) y1, sizeof (y2));
378 bzero (y, sizeof (y) + 0);
379 bzero (y1, 0 + sizeof (y2));
380 bzero ((void *) &c, sizeof (&c));
381 bzero ((signed char *) &c, sizeof (&c));
382 bzero (&c, sizeof (&c) + 0);
383 bzero (&c, 0 + sizeof (&c));
385 /* These are correct, no warning. */
386 bcopy (x, y, sizeof (*y));
387 bcopy (x, y1, sizeof (*y2));
388 bcopy (x, buf1, sizeof buf1);
389 bcopy (x, buf3, sizeof (buf3));
390 bcopy (x, &buf3[0], sizeof (buf3));
391 bcopy (x, &buf4[0], sizeof (buf4));
392 bcopy (y, &y3, sizeof (y3));
393 bcopy (y, (char *) &y3, sizeof (y3));
394 bcopy (x, w, sizeof (X));
395 /* These are probably broken, but obfuscated, no warning. */
396 bcopy (x, (void *) y, sizeof (y));
397 bcopy (x, (char *) y1, sizeof (y2));
398 bcopy (x, y, sizeof (y) + 0);
399 bcopy (x, y1, 0 + sizeof (y2));
400 bcopy (x, (void *) &c, sizeof (&c));
401 bcopy (x, (signed char *) &c, sizeof (&c));
402 bcopy (x, &c, sizeof (&c) + 0);
403 bcopy (x, &c, 0 + sizeof (&c));
405 /* These are correct, no warning. */
406 bcopy (y, x, sizeof (*y));
407 bcopy (y1, x, sizeof (*y2));
408 bcopy (buf1, x, sizeof buf1);
409 bcopy (buf3, x, sizeof (buf3));
410 bcopy (&buf3[0], x, sizeof (buf3));
411 bcopy (&buf4[0], x, sizeof (buf4));
412 bcopy (&y3, y, sizeof (y3));
413 bcopy ((char *) &y3, y, sizeof (y3));
414 bcopy (w, x, sizeof (X));
415 /* These are probably broken, but obfuscated, no warning. */
416 bcopy ((void *) y, x, sizeof (y));
417 bcopy ((char *) y1, x, sizeof (y2));
418 bcopy (y, x, sizeof (y) + 0);
419 bcopy (y1, x, 0 + sizeof (y2));
420 bcopy ((void *) &c, x, sizeof (&c));
421 bcopy ((signed char *) &c, x, sizeof (&c));
422 bcopy (&c, x, sizeof (&c) + 0);
423 bcopy (&c, x, 0 + sizeof (&c));
425 /* These are correct, no warning. */
426 z += bcmp (y, x, sizeof (*y));
427 z += bcmp (y1, x, sizeof (*y2));
428 z += bcmp (buf1, x, sizeof buf1);
429 z += bcmp (buf3, x, sizeof (buf3));
430 z += bcmp (&buf3[0], x, sizeof (buf3));
431 z += bcmp (&buf4[0], x, sizeof (buf4));
432 z += bcmp (&y3, y, sizeof (y3));
433 z += bcmp ((char *) &y3, y, sizeof (y3));
434 z += bcmp (w, x, sizeof (X));
435 /* These are probably broken, but obfuscated, no warning. */
436 z += bcmp ((void *) y, x, sizeof (y));
437 z += bcmp ((char *) y1, x, sizeof (y2));
438 z += bcmp (y, x, sizeof (y) + 0);
439 z += bcmp (y1, x, 0 + sizeof (y2));
440 z += bcmp ((void *) &c, x, sizeof (&c));
441 z += bcmp ((signed char *) &c, x, sizeof (&c));
442 z += bcmp (&c, x, sizeof (&c) + 0);
443 z += bcmp (&c, x, 0 + sizeof (&c));
445 /* These are correct, no warning. */
446 z += bcmp (x, y, sizeof (*y));
447 z += bcmp (x, y1, sizeof (*y2));
448 z += bcmp (x, buf1, sizeof buf1);
449 z += bcmp (x, buf3, sizeof (buf3));
450 z += bcmp (x, &buf3[0], sizeof (buf3));
451 z += bcmp (x, &buf4[0], sizeof (buf4));
452 z += bcmp (y, &y3, sizeof (y3));
453 z += bcmp (y, (char *) &y3, sizeof (y3));
454 z += bcmp (x, w, sizeof (X));
455 /* These are probably broken, but obfuscated, no warning. */
456 z += bcmp (x, (void *) y, sizeof (y));
457 z += bcmp (x, (char *) y1, sizeof (y2));
458 z += bcmp (x, y, sizeof (y) + 0);
459 z += bcmp (x, y1, 0 + sizeof (y2));
460 z += bcmp (x, (void *) &c, sizeof (&c));
461 z += bcmp (x, (signed char *) &c, sizeof (&c));
462 z += bcmp (x, &c, sizeof (&c) + 0);
463 z += bcmp (x, &c, 0 + sizeof (&c));
465 return z;