* gcc.dg/torture/stackalign/builtin-apply-2.c: Fix skip-if syntax.
[official-gcc.git] / gcc / testsuite / gcc.dg / Wsizeof-pointer-memaccess1.c
blobebdef690879be5c620285967ab05627f391e6e55
1 /* Test -Wsizeof-pointer-memaccess warnings. */
2 /* { dg-do compile } */
3 /* { dg-options "-Wall -Wno-sizeof-array-argument" } */
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 /* These are correct, no warning. */
77 bzero (&a, sizeof a);
78 bzero (&a, sizeof (a));
79 bzero (&a, sizeof (struct A));
80 bzero (&a, sizeof (const struct A));
81 bzero (&a, sizeof (volatile struct A));
82 bzero (&a, sizeof (volatile const struct A));
83 bzero (&a, sizeof (TA));
84 bzero (&a, sizeof (__typeof (*&a)));
85 bzero (pa1, sizeof (*pa1));
86 bzero (pa2, sizeof (*pa3));
87 bzero (pa3, sizeof (__typeof (*pa3)));
88 /* These are probably broken, but obfuscated, no warning. */
89 bzero ((void *) &a, sizeof (&a));
90 bzero ((char *) &a, sizeof (&a));
91 bzero (&a, sizeof (&a) + 0);
92 bzero (&a, 0 + sizeof (&a));
94 /* These are correct, no warning. */
95 bcopy (x, &a, sizeof a);
96 bcopy (x, &a, sizeof (a));
97 bcopy (x, &a, sizeof (struct A));
98 bcopy (x, &a, sizeof (const struct A));
99 bcopy (x, &a, sizeof (volatile struct A));
100 bcopy (x, &a, sizeof (volatile const struct A));
101 bcopy (x, &a, sizeof (TA));
102 bcopy (x, &a, sizeof (__typeof (*&a)));
103 bcopy (x, pa1, sizeof (*pa1));
104 bcopy (x, pa2, sizeof (*pa3));
105 bcopy (x, pa3, sizeof (__typeof (*pa3)));
106 /* These are probably broken, but obfuscated, no warning. */
107 bcopy (x, (void *) &a, sizeof (&a));
108 bcopy (x, (char *) &a, sizeof (&a));
109 bcopy (x, &a, sizeof (&a) + 0);
110 bcopy (x, &a, 0 + sizeof (&a));
112 /* These are correct, no warning. */
113 bcopy (&a, x, sizeof a);
114 bcopy (&a, x, sizeof (a));
115 bcopy (&a, x, sizeof (struct A));
116 bcopy (&a, x, sizeof (const struct A));
117 bcopy (&a, x, sizeof (volatile struct A));
118 bcopy (&a, x, sizeof (volatile const struct A));
119 bcopy (&a, x, sizeof (TA));
120 bcopy (&a, x, sizeof (__typeof (*&a)));
121 bcopy (pa1, x, sizeof (*pa1));
122 bcopy (pa2, x, sizeof (*pa3));
123 bcopy (pa3, x, sizeof (__typeof (*pa3)));
124 /* These are probably broken, but obfuscated, no warning. */
125 bcopy ((void *) &a, x, sizeof (&a));
126 bcopy ((char *) &a, x, sizeof (&a));
127 bcopy (&a, x, sizeof (&a) + 0);
128 bcopy (&a, x, 0 + sizeof (&a));
130 /* These are correct, no warning. */
131 z += bcmp (&a, x, sizeof a);
132 z += bcmp (&a, x, sizeof (a));
133 z += bcmp (&a, x, sizeof (struct A));
134 z += bcmp (&a, x, sizeof (const struct A));
135 z += bcmp (&a, x, sizeof (volatile struct A));
136 z += bcmp (&a, x, sizeof (volatile const struct A));
137 z += bcmp (&a, x, sizeof (TA));
138 z += bcmp (&a, x, sizeof (__typeof (*&a)));
139 z += bcmp (pa1, x, sizeof (*pa1));
140 z += bcmp (pa2, x, sizeof (*pa3));
141 z += bcmp (pa3, x, sizeof (__typeof (*pa3)));
142 /* These are probably broken, but obfuscated, no warning. */
143 z += bcmp ((void *) &a, x, sizeof (&a));
144 z += bcmp ((char *) &a, x, sizeof (&a));
145 z += bcmp (&a, x, sizeof (&a) + 0);
146 z += bcmp (&a, x, 0 + sizeof (&a));
148 /* These are correct, no warning. */
149 z += bcmp (x, &a, sizeof a);
150 z += bcmp (x, &a, sizeof (a));
151 z += bcmp (x, &a, sizeof (struct A));
152 z += bcmp (x, &a, sizeof (const struct A));
153 z += bcmp (x, &a, sizeof (volatile struct A));
154 z += bcmp (x, &a, sizeof (volatile const struct A));
155 z += bcmp (x, &a, sizeof (TA));
156 z += bcmp (x, &a, sizeof (__typeof (*&a)));
157 z += bcmp (x, pa1, sizeof (*pa1));
158 z += bcmp (x, pa2, sizeof (*pa3));
159 z += bcmp (x, pa3, sizeof (__typeof (*pa3)));
160 /* These are probably broken, but obfuscated, no warning. */
161 z += bcmp (x, (void *) &a, sizeof (&a));
162 z += bcmp (x, (char *) &a, sizeof (&a));
163 z += bcmp (x, &a, sizeof (&a) + 0);
164 z += bcmp (x, &a, 0 + sizeof (&a));
166 return z;
170 f2 (void *x, int z)
172 struct B b, *pb1 = &b;
173 TB *pb2 = &b;
174 PB pb3 = &b;
175 PTB pb4 = &b;
176 bzero (&b, sizeof (&b)); /* { dg-warning "call is the same expression as the destination; did you mean to remove the addressof" } */
177 bzero (pb1, sizeof (pb1)); /* { dg-warning "call is the same expression as the destination; did you mean to dereference it" } */
178 bzero (pb2, sizeof pb2); /* { dg-warning "call is the same expression as the destination; did you mean to dereference it" } */
179 bzero (pb3, sizeof (pb3)); /* { dg-warning "call is the same expression as the destination; did you mean to dereference it" } */
180 bzero (pb4, sizeof pb4); /* { dg-warning "call is the same expression as the destination; did you mean to dereference it" } */
181 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" } */
182 bzero (pb2, sizeof (PTB)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" } */
183 bzero (pb3, sizeof (PB)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" } */
184 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" } */
186 bcopy (x, &b, sizeof (&b)); /* { dg-warning "call is the same expression as the destination; did you mean to remove the addressof" } */
187 bcopy (x, pb1, sizeof (pb1)); /* { dg-warning "call is the same expression as the destination; did you mean to dereference it" } */
188 bcopy (x, pb2, sizeof pb2); /* { dg-warning "call is the same expression as the destination; did you mean to dereference it" } */
189 bcopy (x, pb3, sizeof (pb3)); /* { dg-warning "call is the same expression as the destination; did you mean to dereference it" } */
190 bcopy (x, pb4, sizeof pb4); /* { dg-warning "call is the same expression as the destination; did you mean to dereference it" } */
191 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" } */
192 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" } */
193 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" } */
194 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" } */
196 bcopy (&b, x, sizeof (&b)); /* { dg-warning "call is the same expression as the source; did you mean to remove the addressof" } */
197 bcopy (pb1, x, sizeof (pb1)); /* { dg-warning "call is the same expression as the source; did you mean to dereference it" } */
198 bcopy (pb2, x, sizeof pb2); /* { dg-warning "call is the same expression as the source; did you mean to dereference it" } */
199 bcopy (pb3, x, sizeof (pb3)); /* { dg-warning "call is the same expression as the source; did you mean to dereference it" } */
200 bcopy (pb4, x, sizeof pb4); /* { dg-warning "call is the same expression as the source; did you mean to dereference it" } */
201 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" } */
202 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" } */
203 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" } */
204 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" } */
206 z += bcmp (&b, x, sizeof (&b)); /* { dg-warning "call is the same expression as the first source; did you mean to remove the addressof" } */
207 z += bcmp (pb1, x, sizeof (pb1)); /* { dg-warning "call is the same expression as the first source; did you mean to dereference it" } */
208 z += bcmp (pb2, x, sizeof pb2); /* { dg-warning "call is the same expression as the first source; did you mean to dereference it" } */
209 z += bcmp (pb3, x, sizeof (pb3)); /* { dg-warning "call is the same expression as the first source; did you mean to dereference it" } */
210 z += bcmp (pb4, x, sizeof pb4); /* { dg-warning "call is the same expression as the first source; did you mean to dereference it" } */
211 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" } */
212 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" } */
213 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" } */
215 z += bcmp (x, &b, sizeof (&b)); /* { dg-warning "call is the same expression as the second source; did you mean to remove the addressof" } */
216 z += bcmp (x, pb1, sizeof (pb1)); /* { dg-warning "call is the same expression as the second source; did you mean to dereference it" } */
217 z += bcmp (x, pb2, sizeof pb2); /* { dg-warning "call is the same expression as the second source; did you mean to dereference it" } */
218 z += bcmp (x, pb3, sizeof (pb3)); /* { dg-warning "call is the same expression as the second source; did you mean to dereference it" } */
219 z += bcmp (x, pb4, sizeof pb4); /* { dg-warning "call is the same expression as the second source; did you mean to dereference it" } */
220 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" } */
221 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" } */
222 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" } */
224 /* These are correct, no warning. */
225 bzero (&b, sizeof b);
226 bzero (&b, sizeof (b));
227 bzero (&b, sizeof (struct B));
228 bzero (&b, sizeof (const struct B));
229 bzero (&b, sizeof (volatile struct B));
230 bzero (&b, sizeof (volatile const struct B));
231 bzero (&b, sizeof (TB));
232 bzero (&b, sizeof (__typeof (*&b)));
233 bzero (pb1, sizeof (*pb1));
234 bzero (pb2, sizeof (*pb3));
235 bzero (pb3, sizeof (__typeof (*pb3)));
236 /* These are probably broken, but obfuscated, no warning. */
237 bzero ((void *) &b, sizeof (&b));
238 bzero ((char *) &b, sizeof (&b));
239 bzero (&b, sizeof (&b) + 0);
240 bzero (&b, 0 + sizeof (&b));
242 /* These are correct, no warning. */
243 bcopy (x, &b, sizeof b);
244 bcopy (x, &b, sizeof (b));
245 bcopy (x, &b, sizeof (struct B));
246 bcopy (x, &b, sizeof (const struct B));
247 bcopy (x, &b, sizeof (volatile struct B));
248 bcopy (x, &b, sizeof (volatile const struct B));
249 bcopy (x, &b, sizeof (TB));
250 bcopy (x, &b, sizeof (__typeof (*&b)));
251 bcopy (x, pb1, sizeof (*pb1));
252 bcopy (x, pb2, sizeof (*pb3));
253 bcopy (x, pb3, sizeof (__typeof (*pb3)));
254 /* These are probably broken, but obfuscated, no warning. */
255 bcopy (x, (void *) &b, sizeof (&b));
256 bcopy (x, (char *) &b, sizeof (&b));
257 bcopy (x, &b, sizeof (&b) + 0);
258 bcopy (x, &b, 0 + sizeof (&b));
260 /* These are correct, no warning. */
261 bcopy (&b, x, sizeof b);
262 bcopy (&b, x, sizeof (b));
263 bcopy (&b, x, sizeof (struct B));
264 bcopy (&b, x, sizeof (const struct B));
265 bcopy (&b, x, sizeof (volatile struct B));
266 bcopy (&b, x, sizeof (volatile const struct B));
267 bcopy (&b, x, sizeof (TB));
268 bcopy (&b, x, sizeof (__typeof (*&b)));
269 bcopy (pb1, x, sizeof (*pb1));
270 bcopy (pb2, x, sizeof (*pb3));
271 bcopy (pb3, x, sizeof (__typeof (*pb3)));
272 /* These are probably broken, but obfuscated, no warning. */
273 bcopy ((void *) &b, x, sizeof (&b));
274 bcopy ((char *) &b, x, sizeof (&b));
275 bcopy (&b, x, sizeof (&b) + 0);
276 bcopy (&b, x, 0 + sizeof (&b));
278 /* These are correct, no warning. */
279 z += bcmp (&b, x, sizeof b);
280 z += bcmp (&b, x, sizeof (b));
281 z += bcmp (&b, x, sizeof (struct B));
282 z += bcmp (&b, x, sizeof (const struct B));
283 z += bcmp (&b, x, sizeof (volatile struct B));
284 z += bcmp (&b, x, sizeof (volatile const struct B));
285 z += bcmp (&b, x, sizeof (TB));
286 z += bcmp (&b, x, sizeof (__typeof (*&b)));
287 z += bcmp (pb1, x, sizeof (*pb1));
288 z += bcmp (pb2, x, sizeof (*pb3));
289 z += bcmp (pb3, x, sizeof (__typeof (*pb3)));
290 /* These are probably broken, but obfuscated, no warning. */
291 z += bcmp ((void *) &b, x, sizeof (&b));
292 z += bcmp ((char *) &b, x, sizeof (&b));
293 z += bcmp (&b, x, sizeof (&b) + 0);
294 z += bcmp (&b, x, 0 + sizeof (&b));
296 /* These are correct, no warning. */
297 z += bcmp (x, &b, sizeof b);
298 z += bcmp (x, &b, sizeof (b));
299 z += bcmp (x, &b, sizeof (struct B));
300 z += bcmp (x, &b, sizeof (const struct B));
301 z += bcmp (x, &b, sizeof (volatile struct B));
302 z += bcmp (x, &b, sizeof (volatile const struct B));
303 z += bcmp (x, &b, sizeof (TB));
304 z += bcmp (x, &b, sizeof (__typeof (*&b)));
305 z += bcmp (x, pb1, sizeof (*pb1));
306 z += bcmp (x, pb2, sizeof (*pb3));
307 z += bcmp (x, pb3, sizeof (__typeof (*pb3)));
308 /* These are probably broken, but obfuscated, no warning. */
309 z += bcmp (x, (void *) &b, sizeof (&b));
310 z += bcmp (x, (char *) &b, sizeof (&b));
311 z += bcmp (x, &b, sizeof (&b) + 0);
312 z += bcmp (x, &b, 0 + sizeof (&b));
314 return z;
318 f3 (void *x, char *y, int z, X w)
320 unsigned char *y1 = (unsigned char *) __builtin_alloca (z + 16);
321 char buf1[7];
322 signed char buf2[z + 32];
323 long buf3[17];
324 int *buf4[9];
325 signed char *y2 = buf2;
326 char c;
327 char *y3;
328 bzero (y, sizeof (y)); /* { dg-warning "call is the same expression as the destination; did you mean to provide an explicit length" } */
329 bzero (y1, sizeof (y1)); /* { dg-warning "call is the same expression as the destination; did you mean to provide an explicit length" } */
330 bzero (y2, sizeof (y2)); /* { dg-warning "call is the same expression as the destination; did you mean to provide an explicit length" } */
331 bzero (&c, sizeof (&c)); /* { dg-warning "call is the same expression as the destination; did you mean to remove the addressof" } */
332 bzero (w, sizeof w); /* { dg-warning "call is the same expression as the destination; did you mean to dereference it" } */
334 bcopy (x, y, sizeof (y)); /* { dg-warning "call is the same expression as the destination; did you mean to provide an explicit length" } */
335 bcopy (x, y1, sizeof (y1)); /* { dg-warning "call is the same expression as the destination; did you mean to provide an explicit length" } */
336 bcopy (x, y2, sizeof (y2)); /* { dg-warning "call is the same expression as the destination; did you mean to provide an explicit length" } */
337 bcopy (x, &c, sizeof (&c)); /* { dg-warning "call is the same expression as the destination; did you mean to remove the addressof" } */
338 bcopy (x, w, sizeof w); /* { dg-warning "call is the same expression as the destination; did you mean to dereference it" } */
340 bcopy (y, x, sizeof (y)); /* { dg-warning "call is the same expression as the source; did you mean to provide an explicit length" } */
341 bcopy (y1, x, sizeof (y1)); /* { dg-warning "call is the same expression as the source; did you mean to provide an explicit length" } */
342 bcopy (y2, x, sizeof (y2)); /* { dg-warning "call is the same expression as the source; did you mean to provide an explicit length" } */
343 bcopy (&c, x, sizeof (&c)); /* { dg-warning "call is the same expression as the source; did you mean to remove the addressof" } */
344 bcopy (w, x, sizeof w); /* { dg-warning "call is the same expression as the source; did you mean to dereference it" } */
346 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" } */
347 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" } */
348 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" } */
349 z += bcmp (&c, x, sizeof (&c)); /* { dg-warning "call is the same expression as the first source; did you mean to remove the addressof" } */
350 z += bcmp (w, x, sizeof w); /* { dg-warning "call is the same expression as the first source; did you mean to dereference it" } */
352 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" } */
353 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" } */
354 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" } */
355 z += bcmp (x, &c, sizeof (&c)); /* { dg-warning "call is the same expression as the second source; did you mean to remove the addressof" } */
356 z += bcmp (x, w, sizeof w); /* { dg-warning "call is the same expression as the second source; did you mean to dereference it" } */
358 /* These are correct, no warning. */
359 bzero (y, sizeof (*y));
360 bzero (y1, sizeof (*y2));
361 bzero (buf1, sizeof buf1);
362 bzero (buf3, sizeof (buf3));
363 bzero (&buf3[0], sizeof (buf3));
364 bzero (&buf4[0], sizeof (buf4));
365 bzero (w, sizeof (X));
366 /* These are probably broken, but obfuscated, no warning. */
367 bzero ((void *) y, sizeof (y));
368 bzero ((char *) y1, sizeof (y2));
369 bzero (y, sizeof (y) + 0);
370 bzero (y1, 0 + sizeof (y2));
371 bzero ((void *) &c, sizeof (&c));
372 bzero ((signed char *) &c, sizeof (&c));
373 bzero (&c, sizeof (&c) + 0);
374 bzero (&c, 0 + sizeof (&c));
376 /* These are correct, no warning. */
377 bcopy (x, y, sizeof (*y));
378 bcopy (x, y1, sizeof (*y2));
379 bcopy (x, buf1, sizeof buf1);
380 bcopy (x, buf3, sizeof (buf3));
381 bcopy (x, &buf3[0], sizeof (buf3));
382 bcopy (x, &buf4[0], sizeof (buf4));
383 bcopy (y, &y3, sizeof (y3));
384 bcopy (y, (char *) &y3, sizeof (y3));
385 bcopy (x, w, sizeof (X));
386 /* These are probably broken, but obfuscated, no warning. */
387 bcopy (x, (void *) y, sizeof (y));
388 bcopy (x, (char *) y1, sizeof (y2));
389 bcopy (x, y, sizeof (y) + 0);
390 bcopy (x, y1, 0 + sizeof (y2));
391 bcopy (x, (void *) &c, sizeof (&c));
392 bcopy (x, (signed char *) &c, sizeof (&c));
393 bcopy (x, &c, sizeof (&c) + 0);
394 bcopy (x, &c, 0 + sizeof (&c));
396 /* These are correct, no warning. */
397 bcopy (y, x, sizeof (*y));
398 bcopy (y1, x, sizeof (*y2));
399 bcopy (buf1, x, sizeof buf1);
400 bcopy (buf3, x, sizeof (buf3));
401 bcopy (&buf3[0], x, sizeof (buf3));
402 bcopy (&buf4[0], x, sizeof (buf4));
403 bcopy (&y3, y, sizeof (y3));
404 bcopy ((char *) &y3, y, sizeof (y3));
405 bcopy (w, x, sizeof (X));
406 /* These are probably broken, but obfuscated, no warning. */
407 bcopy ((void *) y, x, sizeof (y));
408 bcopy ((char *) y1, x, sizeof (y2));
409 bcopy (y, x, sizeof (y) + 0);
410 bcopy (y1, x, 0 + sizeof (y2));
411 bcopy ((void *) &c, x, sizeof (&c));
412 bcopy ((signed char *) &c, x, sizeof (&c));
413 bcopy (&c, x, sizeof (&c) + 0);
414 bcopy (&c, x, 0 + sizeof (&c));
416 /* These are correct, no warning. */
417 z += bcmp (y, x, sizeof (*y));
418 z += bcmp (y1, x, sizeof (*y2));
419 z += bcmp (buf1, x, sizeof buf1);
420 z += bcmp (buf3, x, sizeof (buf3));
421 z += bcmp (&buf3[0], x, sizeof (buf3));
422 z += bcmp (&buf4[0], x, sizeof (buf4));
423 z += bcmp (&y3, y, sizeof (y3));
424 z += bcmp ((char *) &y3, y, sizeof (y3));
425 z += bcmp (w, x, sizeof (X));
426 /* These are probably broken, but obfuscated, no warning. */
427 z += bcmp ((void *) y, x, sizeof (y));
428 z += bcmp ((char *) y1, x, sizeof (y2));
429 z += bcmp (y, x, sizeof (y) + 0);
430 z += bcmp (y1, x, 0 + sizeof (y2));
431 z += bcmp ((void *) &c, x, sizeof (&c));
432 z += bcmp ((signed char *) &c, x, sizeof (&c));
433 z += bcmp (&c, x, sizeof (&c) + 0);
434 z += bcmp (&c, x, 0 + sizeof (&c));
436 /* These are correct, no warning. */
437 z += bcmp (x, y, sizeof (*y));
438 z += bcmp (x, y1, sizeof (*y2));
439 z += bcmp (x, buf1, sizeof buf1);
440 z += bcmp (x, buf3, sizeof (buf3));
441 z += bcmp (x, &buf3[0], sizeof (buf3));
442 z += bcmp (x, &buf4[0], sizeof (buf4));
443 z += bcmp (y, &y3, sizeof (y3));
444 z += bcmp (y, (char *) &y3, sizeof (y3));
445 z += bcmp (x, w, sizeof (X));
446 /* These are probably broken, but obfuscated, no warning. */
447 z += bcmp (x, (void *) y, sizeof (y));
448 z += bcmp (x, (char *) y1, sizeof (y2));
449 z += bcmp (x, y, sizeof (y) + 0);
450 z += bcmp (x, y1, 0 + sizeof (y2));
451 z += bcmp (x, (void *) &c, sizeof (&c));
452 z += bcmp (x, (signed char *) &c, sizeof (&c));
453 z += bcmp (x, &c, sizeof (&c) + 0);
454 z += bcmp (x, &c, 0 + sizeof (&c));
456 return z;