Rebase.
[official-gcc.git] / gcc / testsuite / gcc.dg / torture / Wsizeof-pointer-memaccess1.c
bloba82f4efbdafabd1f2a7eb7c8c58de0678ae123e7
1 /* Test -Wsizeof-pointer-memaccess warnings. */
2 /* { dg-do compile } */
3 /* { dg-options "-Wall -Wno-sizeof-array-argument" } */
4 /* Test just twice, once with -O0 non-fortified, once with -O2 fortified. */
5 /* { dg-skip-if "" { *-*-* } { "*" } { "-O0" "-O2" } } */
6 /* { dg-skip-if "" { *-*-* } { "-flto" } { "" } } */
8 typedef __SIZE_TYPE__ size_t;
9 extern void *memset (void *, int, size_t);
10 extern void *memcpy (void *__restrict, const void *__restrict, size_t);
11 extern void *memmove (void *__restrict, const void *__restrict, size_t);
12 extern int memcmp (const void *, const void *, size_t);
13 extern char *strncpy (char *__restrict, const char *__restrict, size_t);
14 extern char *strncat (char *__restrict, const char *__restrict, size_t);
15 extern char *stpncpy (char *__restrict, const char *__restrict, size_t);
16 extern char *strndup (const char *, size_t);
17 extern int strncmp (const char *, const char *, size_t);
18 extern int strncasecmp (const char *, const char *, size_t);
20 #ifdef __OPTIMIZE__
21 # define bos(ptr) __builtin_object_size (ptr, 1)
22 # define bos0(ptr) __builtin_object_size (ptr, 0)
24 __attribute__((__always_inline__, __gnu_inline__, __artificial__))
25 extern inline void *
26 memset (void *dest, int c, size_t len)
28 return __builtin___memset_chk (dest, c, len, bos0 (dest));
31 __attribute__((__always_inline__, __gnu_inline__, __artificial__))
32 extern inline void *
33 memcpy (void *__restrict dest, const void *__restrict src, size_t len)
35 return __builtin___memcpy_chk (dest, src, len, bos0 (dest));
38 __attribute__((__always_inline__, __gnu_inline__, __artificial__))
39 extern inline void *
40 memmove (void *dest, const void *src, size_t len)
42 return __builtin___memmove_chk (dest, src, len, bos0 (dest));
45 __attribute__((__always_inline__, __gnu_inline__, __artificial__))
46 extern inline char *
47 strncpy (char *__restrict dest, const char *__restrict src, size_t len)
49 return __builtin___strncpy_chk (dest, src, len, bos (dest));
52 __attribute__((__always_inline__, __gnu_inline__, __artificial__))
53 extern inline char *
54 strncat (char *dest, const char *src, size_t len)
56 return __builtin___strncat_chk (dest, src, len, bos (dest));
59 __attribute__((__always_inline__, __gnu_inline__, __artificial__))
60 extern inline char *
61 stpncpy (char *__restrict dest, const char *__restrict src, size_t len)
63 return __builtin___stpncpy_chk (dest, src, len, bos (dest));
65 #endif
67 struct A { short a, b; int c, d; long e, f; };
68 typedef struct A TA;
69 typedef struct A *PA;
70 typedef TA *PTA;
71 struct B {};
72 typedef struct B TB;
73 typedef struct B *PB;
74 typedef TB *PTB;
75 typedef int X[3][3][3];
77 int
78 f1 (void *x, int z)
80 struct A a, *pa1 = &a;
81 TA *pa2 = &a;
82 PA pa3 = &a;
83 PTA pa4 = &a;
84 memset (&a, 0, sizeof (&a)); /* { dg-warning "call is the same expression as the destination; did you mean to remove the addressof" } */
85 memset (pa1, 0, sizeof (pa1)); /* { dg-warning "call is the same expression as the destination; did you mean to dereference it" } */
86 memset (pa2, 0, sizeof pa2); /* { dg-warning "call is the same expression as the destination; did you mean to dereference it" } */
87 memset (pa3, 0, sizeof (pa3)); /* { dg-warning "call is the same expression as the destination; did you mean to dereference it" } */
88 memset (pa4, 0, sizeof pa4); /* { dg-warning "call is the same expression as the destination; did you mean to dereference it" } */
89 memset (pa1, 0, sizeof (struct A *)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" } */
90 memset (pa2, 0, sizeof (PTA)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" } */
91 memset (pa3, 0, sizeof (PA)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" } */
92 memset (pa4, 0, sizeof (__typeof (pa4))); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" } */
94 memcpy (&a, x, sizeof (&a)); /* { dg-warning "call is the same expression as the destination; did you mean to remove the addressof" } */
95 memcpy (pa1, x, sizeof (pa1)); /* { dg-warning "call is the same expression as the destination; did you mean to dereference it" } */
96 memcpy (pa2, x, sizeof pa2); /* { dg-warning "call is the same expression as the destination; did you mean to dereference it" } */
97 memcpy (pa3, x, sizeof (pa3)); /* { dg-warning "call is the same expression as the destination; did you mean to dereference it" } */
98 memcpy (pa4, x, sizeof pa4); /* { dg-warning "call is the same expression as the destination; did you mean to dereference it" } */
99 memcpy (pa1, x, sizeof (struct A *)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" } */
100 memcpy (pa2, x, sizeof (PTA)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" } */
101 memcpy (pa3, x, sizeof (PA)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" } */
102 memcpy (pa4, x, sizeof (__typeof (pa4))); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" } */
104 memcpy (x, &a, sizeof (&a)); /* { dg-warning "call is the same expression as the source; did you mean to remove the addressof" } */
105 memcpy (x, pa1, sizeof (pa1)); /* { dg-warning "call is the same expression as the source; did you mean to dereference it" } */
106 memcpy (x, pa2, sizeof pa2); /* { dg-warning "call is the same expression as the source; did you mean to dereference it" } */
107 memcpy (x, pa3, sizeof (pa3)); /* { dg-warning "call is the same expression as the source; did you mean to dereference it" } */
108 memcpy (x, pa4, sizeof pa4); /* { dg-warning "call is the same expression as the source; did you mean to dereference it" } */
109 memcpy (x, pa1, sizeof (struct A *)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the source; expected \[^\n\r\]* or an explicit length" } */
110 memcpy (x, pa2, sizeof (PTA)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the source; expected \[^\n\r\]* or an explicit length" } */
111 memcpy (x, pa3, sizeof (PA)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the source; expected \[^\n\r\]* or an explicit length" } */
112 memcpy (x, pa4, sizeof (__typeof (pa4))); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the source; expected \[^\n\r\]* or an explicit length" } */
114 memmove (&a, x, sizeof (&a)); /* { dg-warning "call is the same expression as the destination; did you mean to remove the addressof" } */
115 memmove (pa1, x, sizeof (pa1)); /* { dg-warning "call is the same expression as the destination; did you mean to dereference it" } */
116 memmove (pa2, x, sizeof pa2); /* { dg-warning "call is the same expression as the destination; did you mean to dereference it" } */
117 memmove (pa3, x, sizeof (pa3)); /* { dg-warning "call is the same expression as the destination; did you mean to dereference it" } */
118 memmove (pa4, x, sizeof pa4); /* { dg-warning "call is the same expression as the destination; did you mean to dereference it" } */
119 memmove (pa1, x, sizeof (struct A *)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" } */
120 memmove (pa2, x, sizeof (PTA)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" } */
121 memmove (pa3, x, sizeof (PA)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" } */
122 memmove (pa4, x, sizeof (__typeof (pa4)));/* { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" } */
124 memmove (x, &a, sizeof (&a)); /* { dg-warning "call is the same expression as the source; did you mean to remove the addressof" } */
125 memmove (x, pa1, sizeof (pa1)); /* { dg-warning "call is the same expression as the source; did you mean to dereference it" } */
126 memmove (x, pa2, sizeof pa2); /* { dg-warning "call is the same expression as the source; did you mean to dereference it" } */
127 memmove (x, pa3, sizeof (pa3)); /* { dg-warning "call is the same expression as the source; did you mean to dereference it" } */
128 memmove (x, pa4, sizeof pa4); /* { dg-warning "call is the same expression as the source; did you mean to dereference it" } */
129 memmove (x, pa1, sizeof (struct A *)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the source; expected \[^\n\r\]* or an explicit length" } */
130 memmove (x, pa2, sizeof (PTA)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the source; expected \[^\n\r\]* or an explicit length" } */
131 memmove (x, pa3, sizeof (PA)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the source; expected \[^\n\r\]* or an explicit length" } */
132 memmove (x, pa4, sizeof (__typeof (pa4)));/* { dg-warning "call is the same pointer type \[^\n\r\]* as the source; expected \[^\n\r\]* or an explicit length" } */
134 z += memcmp (&a, x, sizeof (&a)); /* { dg-warning "call is the same expression as the first source; did you mean to remove the addressof" } */
135 z += memcmp (pa1, x, sizeof (pa1)); /* { dg-warning "call is the same expression as the first source; did you mean to dereference it" } */
136 z += memcmp (pa2, x, sizeof pa2); /* { dg-warning "call is the same expression as the first source; did you mean to dereference it" } */
137 z += memcmp (pa3, x, sizeof (pa3)); /* { dg-warning "call is the same expression as the first source; did you mean to dereference it" } */
138 z += memcmp (pa4, x, sizeof pa4); /* { dg-warning "call is the same expression as the first source; did you mean to dereference it" } */
139 z += memcmp (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" } */
140 z += memcmp (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" } */
141 z += memcmp (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" } */
143 z += memcmp (x, &a, sizeof (&a)); /* { dg-warning "call is the same expression as the second source; did you mean to remove the addressof" } */
144 z += memcmp (x, pa1, sizeof (pa1)); /* { dg-warning "call is the same expression as the second source; did you mean to dereference it" } */
145 z += memcmp (x, pa2, sizeof pa2); /* { dg-warning "call is the same expression as the second source; did you mean to dereference it" } */
146 z += memcmp (x, pa3, sizeof (pa3)); /* { dg-warning "call is the same expression as the second source; did you mean to dereference it" } */
147 z += memcmp (x, pa4, sizeof pa4); /* { dg-warning "call is the same expression as the second source; did you mean to dereference it" } */
148 z += memcmp (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" } */
149 z += memcmp (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" } */
150 z += memcmp (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" } */
152 /* These are correct, no warning. */
153 memset (&a, 0, sizeof a);
154 memset (&a, 0, sizeof (a));
155 memset (&a, 0, sizeof (struct A));
156 memset (&a, 0, sizeof (const struct A));
157 memset (&a, 0, sizeof (volatile struct A));
158 memset (&a, 0, sizeof (volatile const struct A));
159 memset (&a, 0, sizeof (TA));
160 memset (&a, 0, sizeof (__typeof (*&a)));
161 memset (pa1, 0, sizeof (*pa1));
162 memset (pa2, 0, sizeof (*pa3));
163 memset (pa3, 0, sizeof (__typeof (*pa3)));
164 /* These are probably broken, but obfuscated, no warning. */
165 memset ((void *) &a, 0, sizeof (&a));
166 memset ((char *) &a, 0, sizeof (&a));
167 memset (&a, 0, sizeof (&a) + 0);
168 memset (&a, 0, 0 + sizeof (&a));
170 /* These are correct, no warning. */
171 memcpy (&a, x, sizeof a);
172 memcpy (&a, x, sizeof (a));
173 memcpy (&a, x, sizeof (struct A));
174 memcpy (&a, x, sizeof (const struct A));
175 memcpy (&a, x, sizeof (volatile struct A));
176 memcpy (&a, x, sizeof (volatile const struct A));
177 memcpy (&a, x, sizeof (TA));
178 memcpy (&a, x, sizeof (__typeof (*&a)));
179 memcpy (pa1, x, sizeof (*pa1));
180 memcpy (pa2, x, sizeof (*pa3));
181 memcpy (pa3, x, sizeof (__typeof (*pa3)));
182 /* These are probably broken, but obfuscated, no warning. */
183 memcpy ((void *) &a, x, sizeof (&a));
184 memcpy ((char *) &a, x, sizeof (&a));
185 memcpy (&a, x, sizeof (&a) + 0);
186 memcpy (&a, x, 0 + sizeof (&a));
188 /* These are correct, no warning. */
189 memcpy (x, &a, sizeof a);
190 memcpy (x, &a, sizeof (a));
191 memcpy (x, &a, sizeof (struct A));
192 memcpy (x, &a, sizeof (const struct A));
193 memcpy (x, &a, sizeof (volatile struct A));
194 memcpy (x, &a, sizeof (volatile const struct A));
195 memcpy (x, &a, sizeof (TA));
196 memcpy (x, &a, sizeof (__typeof (*&a)));
197 memcpy (x, pa1, sizeof (*pa1));
198 memcpy (x, pa2, sizeof (*pa3));
199 memcpy (x, pa3, sizeof (__typeof (*pa3)));
200 /* These are probably broken, but obfuscated, no warning. */
201 memcpy (x, (void *) &a, sizeof (&a));
202 memcpy (x, (char *) &a, sizeof (&a));
203 memcpy (x, &a, sizeof (&a) + 0);
204 memcpy (x, &a, 0 + sizeof (&a));
206 /* These are correct, no warning. */
207 memmove (&a, x, sizeof a);
208 memmove (&a, x, sizeof (a));
209 memmove (&a, x, sizeof (struct A));
210 memmove (&a, x, sizeof (const struct A));
211 memmove (&a, x, sizeof (volatile struct A));
212 memmove (&a, x, sizeof (volatile const struct A));
213 memmove (&a, x, sizeof (TA));
214 memmove (&a, x, sizeof (__typeof (*&a)));
215 memmove (pa1, x, sizeof (*pa1));
216 memmove (pa2, x, sizeof (*pa3));
217 memmove (pa3, x, sizeof (__typeof (*pa3)));
218 /* These are probably broken, but obfuscated, no warning. */
219 memmove ((void *) &a, x, sizeof (&a));
220 memmove ((char *) &a, x, sizeof (&a));
221 memmove (&a, x, sizeof (&a) + 0);
222 memmove (&a, x, 0 + sizeof (&a));
224 /* These are correct, no warning. */
225 memmove (x, &a, sizeof a);
226 memmove (x, &a, sizeof (a));
227 memmove (x, &a, sizeof (struct A));
228 memmove (x, &a, sizeof (const struct A));
229 memmove (x, &a, sizeof (volatile struct A));
230 memmove (x, &a, sizeof (volatile const struct A));
231 memmove (x, &a, sizeof (TA));
232 memmove (x, &a, sizeof (__typeof (*&a)));
233 memmove (x, pa1, sizeof (*pa1));
234 memmove (x, pa2, sizeof (*pa3));
235 memmove (x, pa3, sizeof (__typeof (*pa3)));
236 /* These are probably broken, but obfuscated, no warning. */
237 memmove (x, (void *) &a, sizeof (&a));
238 memmove (x, (char *) &a, sizeof (&a));
239 memmove (x, &a, sizeof (&a) + 0);
240 memmove (x, &a, 0 + sizeof (&a));
242 /* These are correct, no warning. */
243 z += memcmp (&a, x, sizeof a);
244 z += memcmp (&a, x, sizeof (a));
245 z += memcmp (&a, x, sizeof (struct A));
246 z += memcmp (&a, x, sizeof (const struct A));
247 z += memcmp (&a, x, sizeof (volatile struct A));
248 z += memcmp (&a, x, sizeof (volatile const struct A));
249 z += memcmp (&a, x, sizeof (TA));
250 z += memcmp (&a, x, sizeof (__typeof (*&a)));
251 z += memcmp (pa1, x, sizeof (*pa1));
252 z += memcmp (pa2, x, sizeof (*pa3));
253 z += memcmp (pa3, x, sizeof (__typeof (*pa3)));
254 /* These are probably broken, but obfuscated, no warning. */
255 z += memcmp ((void *) &a, x, sizeof (&a));
256 z += memcmp ((char *) &a, x, sizeof (&a));
257 z += memcmp (&a, x, sizeof (&a) + 0);
258 z += memcmp (&a, x, 0 + sizeof (&a));
260 /* These are correct, no warning. */
261 z += memcmp (x, &a, sizeof a);
262 z += memcmp (x, &a, sizeof (a));
263 z += memcmp (x, &a, sizeof (struct A));
264 z += memcmp (x, &a, sizeof (const struct A));
265 z += memcmp (x, &a, sizeof (volatile struct A));
266 z += memcmp (x, &a, sizeof (volatile const struct A));
267 z += memcmp (x, &a, sizeof (TA));
268 z += memcmp (x, &a, sizeof (__typeof (*&a)));
269 z += memcmp (x, pa1, sizeof (*pa1));
270 z += memcmp (x, pa2, sizeof (*pa3));
271 z += memcmp (x, pa3, sizeof (__typeof (*pa3)));
272 /* These are probably broken, but obfuscated, no warning. */
273 z += memcmp (x, (void *) &a, sizeof (&a));
274 z += memcmp (x, (char *) &a, sizeof (&a));
275 z += memcmp (x, &a, sizeof (&a) + 0);
276 z += memcmp (x, &a, 0 + sizeof (&a));
278 return z;
282 f2 (void *x, int z)
284 struct B b, *pb1 = &b;
285 TB *pb2 = &b;
286 PB pb3 = &b;
287 PTB pb4 = &b;
288 memset (&b, 0, sizeof (&b)); /* { dg-warning "call is the same expression as the destination; did you mean to remove the addressof" } */
289 memset (pb1, 0, sizeof (pb1)); /* { dg-warning "call is the same expression as the destination; did you mean to dereference it" } */
290 memset (pb2, 0, sizeof pb2); /* { dg-warning "call is the same expression as the destination; did you mean to dereference it" } */
291 memset (pb3, 0, sizeof (pb3)); /* { dg-warning "call is the same expression as the destination; did you mean to dereference it" } */
292 memset (pb4, 0, sizeof pb4); /* { dg-warning "call is the same expression as the destination; did you mean to dereference it" } */
293 memset (pb1, 0, sizeof (struct B *)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" } */
294 memset (pb2, 0, sizeof (PTB)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" } */
295 memset (pb3, 0, sizeof (PB)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" } */
296 memset (pb4, 0, sizeof (__typeof (pb4))); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" } */
298 memcpy (&b, x, sizeof (&b)); /* { dg-warning "call is the same expression as the destination; did you mean to remove the addressof" } */
299 memcpy (pb1, x, sizeof (pb1)); /* { dg-warning "call is the same expression as the destination; did you mean to dereference it" } */
300 memcpy (pb2, x, sizeof pb2); /* { dg-warning "call is the same expression as the destination; did you mean to dereference it" } */
301 memcpy (pb3, x, sizeof (pb3)); /* { dg-warning "call is the same expression as the destination; did you mean to dereference it" } */
302 memcpy (pb4, x, sizeof pb4); /* { dg-warning "call is the same expression as the destination; did you mean to dereference it" } */
303 memcpy (pb1, x, sizeof (struct B *)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" } */
304 memcpy (pb2, x, sizeof (PTB)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" } */
305 memcpy (pb3, x, sizeof (PB)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" } */
306 memcpy (pb4, x, sizeof (__typeof (pb4))); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" } */
308 memcpy (x, &b, sizeof (&b)); /* { dg-warning "call is the same expression as the source; did you mean to remove the addressof" } */
309 memcpy (x, pb1, sizeof (pb1)); /* { dg-warning "call is the same expression as the source; did you mean to dereference it" } */
310 memcpy (x, pb2, sizeof pb2); /* { dg-warning "call is the same expression as the source; did you mean to dereference it" } */
311 memcpy (x, pb3, sizeof (pb3)); /* { dg-warning "call is the same expression as the source; did you mean to dereference it" } */
312 memcpy (x, pb4, sizeof pb4); /* { dg-warning "call is the same expression as the source; did you mean to dereference it" } */
313 memcpy (x, pb1, sizeof (struct B *)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the source; expected \[^\n\r\]* or an explicit length" } */
314 memcpy (x, pb2, sizeof (PTB)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the source; expected \[^\n\r\]* or an explicit length" } */
315 memcpy (x, pb3, sizeof (PB)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the source; expected \[^\n\r\]* or an explicit length" } */
316 memcpy (x, pb4, sizeof (__typeof (pb4))); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the source; expected \[^\n\r\]* or an explicit length" } */
318 memmove (&b, x, sizeof (&b)); /* { dg-warning "call is the same expression as the destination; did you mean to remove the addressof" } */
319 memmove (pb1, x, sizeof (pb1)); /* { dg-warning "call is the same expression as the destination; did you mean to dereference it" } */
320 memmove (pb2, x, sizeof pb2); /* { dg-warning "call is the same expression as the destination; did you mean to dereference it" } */
321 memmove (pb3, x, sizeof (pb3)); /* { dg-warning "call is the same expression as the destination; did you mean to dereference it" } */
322 memmove (pb4, x, sizeof pb4); /* { dg-warning "call is the same expression as the destination; did you mean to dereference it" } */
323 memmove (pb1, x, sizeof (struct B *)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" } */
324 memmove (pb2, x, sizeof (PTB)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" } */
325 memmove (pb3, x, sizeof (PB)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" } */
326 memmove (pb4, x, sizeof (__typeof (pb4)));/* { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" } */
328 memmove (x, &b, sizeof (&b)); /* { dg-warning "call is the same expression as the source; did you mean to remove the addressof" } */
329 memmove (x, pb1, sizeof (pb1)); /* { dg-warning "call is the same expression as the source; did you mean to dereference it" } */
330 memmove (x, pb2, sizeof pb2); /* { dg-warning "call is the same expression as the source; did you mean to dereference it" } */
331 memmove (x, pb3, sizeof (pb3)); /* { dg-warning "call is the same expression as the source; did you mean to dereference it" } */
332 memmove (x, pb4, sizeof pb4); /* { dg-warning "call is the same expression as the source; did you mean to dereference it" } */
333 memmove (x, pb1, sizeof (struct B *)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the source; expected \[^\n\r\]* or an explicit length" } */
334 memmove (x, pb2, sizeof (PTB)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the source; expected \[^\n\r\]* or an explicit length" } */
335 memmove (x, pb3, sizeof (PB)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the source; expected \[^\n\r\]* or an explicit length" } */
336 memmove (x, pb4, sizeof (__typeof (pb4)));/* { dg-warning "call is the same pointer type \[^\n\r\]* as the source; expected \[^\n\r\]* or an explicit length" } */
338 z += memcmp (&b, x, sizeof (&b)); /* { dg-warning "call is the same expression as the first source; did you mean to remove the addressof" } */
339 z += memcmp (pb1, x, sizeof (pb1)); /* { dg-warning "call is the same expression as the first source; did you mean to dereference it" } */
340 z += memcmp (pb2, x, sizeof pb2); /* { dg-warning "call is the same expression as the first source; did you mean to dereference it" } */
341 z += memcmp (pb3, x, sizeof (pb3)); /* { dg-warning "call is the same expression as the first source; did you mean to dereference it" } */
342 z += memcmp (pb4, x, sizeof pb4); /* { dg-warning "call is the same expression as the first source; did you mean to dereference it" } */
343 z += memcmp (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" } */
344 z += memcmp (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" } */
345 z += memcmp (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" } */
347 z += memcmp (x, &b, sizeof (&b)); /* { dg-warning "call is the same expression as the second source; did you mean to remove the addressof" } */
348 z += memcmp (x, pb1, sizeof (pb1)); /* { dg-warning "call is the same expression as the second source; did you mean to dereference it" } */
349 z += memcmp (x, pb2, sizeof pb2); /* { dg-warning "call is the same expression as the second source; did you mean to dereference it" } */
350 z += memcmp (x, pb3, sizeof (pb3)); /* { dg-warning "call is the same expression as the second source; did you mean to dereference it" } */
351 z += memcmp (x, pb4, sizeof pb4); /* { dg-warning "call is the same expression as the second source; did you mean to dereference it" } */
352 z += memcmp (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" } */
353 z += memcmp (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" } */
354 z += memcmp (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" } */
356 /* These are correct, no warning. */
357 memset (&b, 0, sizeof b);
358 memset (&b, 0, sizeof (b));
359 memset (&b, 0, sizeof (struct B));
360 memset (&b, 0, sizeof (const struct B));
361 memset (&b, 0, sizeof (volatile struct B));
362 memset (&b, 0, sizeof (volatile const struct B));
363 memset (&b, 0, sizeof (TB));
364 memset (&b, 0, sizeof (__typeof (*&b)));
365 memset (pb1, 0, sizeof (*pb1));
366 memset (pb2, 0, sizeof (*pb3));
367 memset (pb3, 0, sizeof (__typeof (*pb3)));
368 /* These are probably broken, but obfuscated, no warning. */
369 memset ((void *) &b, 0, sizeof (&b));
370 memset ((char *) &b, 0, sizeof (&b));
371 memset (&b, 0, sizeof (&b) + 0);
372 memset (&b, 0, 0 + sizeof (&b));
374 /* These are correct, no warning. */
375 memcpy (&b, x, sizeof b);
376 memcpy (&b, x, sizeof (b));
377 memcpy (&b, x, sizeof (struct B));
378 memcpy (&b, x, sizeof (const struct B));
379 memcpy (&b, x, sizeof (volatile struct B));
380 memcpy (&b, x, sizeof (volatile const struct B));
381 memcpy (&b, x, sizeof (TB));
382 memcpy (&b, x, sizeof (__typeof (*&b)));
383 memcpy (pb1, x, sizeof (*pb1));
384 memcpy (pb2, x, sizeof (*pb3));
385 memcpy (pb3, x, sizeof (__typeof (*pb3)));
386 /* These are probably broken, but obfuscated, no warning. */
387 memcpy ((void *) &b, x, sizeof (&b));
388 memcpy ((char *) &b, x, sizeof (&b));
389 memcpy (&b, x, sizeof (&b) + 0);
390 memcpy (&b, x, 0 + sizeof (&b));
392 /* These are correct, no warning. */
393 memcpy (x, &b, sizeof b);
394 memcpy (x, &b, sizeof (b));
395 memcpy (x, &b, sizeof (struct B));
396 memcpy (x, &b, sizeof (const struct B));
397 memcpy (x, &b, sizeof (volatile struct B));
398 memcpy (x, &b, sizeof (volatile const struct B));
399 memcpy (x, &b, sizeof (TB));
400 memcpy (x, &b, sizeof (__typeof (*&b)));
401 memcpy (x, pb1, sizeof (*pb1));
402 memcpy (x, pb2, sizeof (*pb3));
403 memcpy (x, pb3, sizeof (__typeof (*pb3)));
404 /* These are probably broken, but obfuscated, no warning. */
405 memcpy (x, (void *) &b, sizeof (&b));
406 memcpy (x, (char *) &b, sizeof (&b));
407 memcpy (x, &b, sizeof (&b) + 0);
408 memcpy (x, &b, 0 + sizeof (&b));
410 /* These are correct, no warning. */
411 memmove (&b, x, sizeof b);
412 memmove (&b, x, sizeof (b));
413 memmove (&b, x, sizeof (struct B));
414 memmove (&b, x, sizeof (const struct B));
415 memmove (&b, x, sizeof (volatile struct B));
416 memmove (&b, x, sizeof (volatile const struct B));
417 memmove (&b, x, sizeof (TB));
418 memmove (&b, x, sizeof (__typeof (*&b)));
419 memmove (pb1, x, sizeof (*pb1));
420 memmove (pb2, x, sizeof (*pb3));
421 memmove (pb3, x, sizeof (__typeof (*pb3)));
422 /* These are probably broken, but obfuscated, no warning. */
423 memmove ((void *) &b, x, sizeof (&b));
424 memmove ((char *) &b, x, sizeof (&b));
425 memmove (&b, x, sizeof (&b) + 0);
426 memmove (&b, x, 0 + sizeof (&b));
428 /* These are correct, no warning. */
429 memmove (x, &b, sizeof b);
430 memmove (x, &b, sizeof (b));
431 memmove (x, &b, sizeof (struct B));
432 memmove (x, &b, sizeof (const struct B));
433 memmove (x, &b, sizeof (volatile struct B));
434 memmove (x, &b, sizeof (volatile const struct B));
435 memmove (x, &b, sizeof (TB));
436 memmove (x, &b, sizeof (__typeof (*&b)));
437 memmove (x, pb1, sizeof (*pb1));
438 memmove (x, pb2, sizeof (*pb3));
439 memmove (x, pb3, sizeof (__typeof (*pb3)));
440 /* These are probably broken, but obfuscated, no warning. */
441 memmove (x, (void *) &b, sizeof (&b));
442 memmove (x, (char *) &b, sizeof (&b));
443 memmove (x, &b, sizeof (&b) + 0);
444 memmove (x, &b, 0 + sizeof (&b));
446 /* These are correct, no warning. */
447 z += memcmp (&b, x, sizeof b);
448 z += memcmp (&b, x, sizeof (b));
449 z += memcmp (&b, x, sizeof (struct B));
450 z += memcmp (&b, x, sizeof (const struct B));
451 z += memcmp (&b, x, sizeof (volatile struct B));
452 z += memcmp (&b, x, sizeof (volatile const struct B));
453 z += memcmp (&b, x, sizeof (TB));
454 z += memcmp (&b, x, sizeof (__typeof (*&b)));
455 z += memcmp (pb1, x, sizeof (*pb1));
456 z += memcmp (pb2, x, sizeof (*pb3));
457 z += memcmp (pb3, x, sizeof (__typeof (*pb3)));
458 /* These are probably broken, but obfuscated, no warning. */
459 z += memcmp ((void *) &b, x, sizeof (&b));
460 z += memcmp ((char *) &b, x, sizeof (&b));
461 z += memcmp (&b, x, sizeof (&b) + 0);
462 z += memcmp (&b, x, 0 + sizeof (&b));
464 /* These are correct, no warning. */
465 z += memcmp (x, &b, sizeof b);
466 z += memcmp (x, &b, sizeof (b));
467 z += memcmp (x, &b, sizeof (struct B));
468 z += memcmp (x, &b, sizeof (const struct B));
469 z += memcmp (x, &b, sizeof (volatile struct B));
470 z += memcmp (x, &b, sizeof (volatile const struct B));
471 z += memcmp (x, &b, sizeof (TB));
472 z += memcmp (x, &b, sizeof (__typeof (*&b)));
473 z += memcmp (x, pb1, sizeof (*pb1));
474 z += memcmp (x, pb2, sizeof (*pb3));
475 z += memcmp (x, pb3, sizeof (__typeof (*pb3)));
476 /* These are probably broken, but obfuscated, no warning. */
477 z += memcmp (x, (void *) &b, sizeof (&b));
478 z += memcmp (x, (char *) &b, sizeof (&b));
479 z += memcmp (x, &b, sizeof (&b) + 0);
480 z += memcmp (x, &b, 0 + sizeof (&b));
482 return z;
486 f3 (void *x, char *y, int z, X w)
488 unsigned char *y1 = (unsigned char *) __builtin_alloca (z + 16);
489 char buf1[7];
490 signed char buf2[z + 32];
491 long buf3[17];
492 int *buf4[9];
493 signed char *y2 = buf2;
494 char c;
495 char *y3;
496 memset (y, 0, sizeof (y)); /* { dg-warning "call is the same expression as the destination; did you mean to provide an explicit length" } */
497 memset (y1, 0, sizeof (y1)); /* { dg-warning "call is the same expression as the destination; did you mean to provide an explicit length" } */
498 memset (y2, 0, sizeof (y2)); /* { dg-warning "call is the same expression as the destination; did you mean to provide an explicit length" } */
499 memset (&c, 0, sizeof (&c)); /* { dg-warning "call is the same expression as the destination; did you mean to remove the addressof" } */
500 memset (w, 0, sizeof w); /* { dg-warning "call is the same expression as the destination; did you mean to dereference it" } */
502 memcpy (y, x, sizeof (y)); /* { dg-warning "call is the same expression as the destination; did you mean to provide an explicit length" } */
503 memcpy (y1, x, sizeof (y1)); /* { dg-warning "call is the same expression as the destination; did you mean to provide an explicit length" } */
504 memcpy (y2, x, sizeof (y2)); /* { dg-warning "call is the same expression as the destination; did you mean to provide an explicit length" } */
505 memcpy (&c, x, sizeof (&c)); /* { dg-warning "call is the same expression as the destination; did you mean to remove the addressof" } */
506 memcpy (w, x, sizeof w); /* { dg-warning "call is the same expression as the destination; did you mean to dereference it" } */
508 memcpy (x, y, sizeof (y)); /* { dg-warning "call is the same expression as the source; did you mean to provide an explicit length" } */
509 memcpy (x, y1, sizeof (y1)); /* { dg-warning "call is the same expression as the source; did you mean to provide an explicit length" } */
510 memcpy (x, y2, sizeof (y2)); /* { dg-warning "call is the same expression as the source; did you mean to provide an explicit length" } */
511 memcpy (x, &c, sizeof (&c)); /* { dg-warning "call is the same expression as the source; did you mean to remove the addressof" } */
512 memcpy (x, w, sizeof w); /* { dg-warning "call is the same expression as the source; did you mean to dereference it" } */
514 memmove (y, x, sizeof (y)); /* { dg-warning "call is the same expression as the destination; did you mean to provide an explicit length" } */
515 memmove (y1, x, sizeof (y1)); /* { dg-warning "call is the same expression as the destination; did you mean to provide an explicit length" } */
516 memmove (y2, x, sizeof (y2)); /* { dg-warning "call is the same expression as the destination; did you mean to provide an explicit length" } */
517 memmove (&c, x, sizeof (&c)); /* { dg-warning "call is the same expression as the destination; did you mean to remove the addressof" } */
518 memmove (w, x, sizeof w); /* { dg-warning "call is the same expression as the destination; did you mean to dereference it" } */
520 memmove (x, y, sizeof (y)); /* { dg-warning "call is the same expression as the source; did you mean to provide an explicit length" } */
521 memmove (x, y1, sizeof (y1)); /* { dg-warning "call is the same expression as the source; did you mean to provide an explicit length" } */
522 memmove (x, y2, sizeof (y2)); /* { dg-warning "call is the same expression as the source; did you mean to provide an explicit length" } */
523 memmove (x, &c, sizeof (&c)); /* { dg-warning "call is the same expression as the source; did you mean to remove the addressof" } */
524 memmove (x, w, sizeof w); /* { dg-warning "call is the same expression as the source; did you mean to dereference it" } */
526 z += memcmp (y, x, sizeof (y)); /* { dg-warning "call is the same expression as the first source; did you mean to provide an explicit length" } */
527 z += memcmp (y1, x, sizeof (y1)); /* { dg-warning "call is the same expression as the first source; did you mean to provide an explicit length" } */
528 z += memcmp (y2, x, sizeof (y2)); /* { dg-warning "call is the same expression as the first source; did you mean to provide an explicit length" } */
529 z += memcmp (&c, x, sizeof (&c)); /* { dg-warning "call is the same expression as the first source; did you mean to remove the addressof" } */
530 z += memcmp (w, x, sizeof w); /* { dg-warning "call is the same expression as the first source; did you mean to dereference it" } */
532 z += memcmp (x, y, sizeof (y)); /* { dg-warning "call is the same expression as the second source; did you mean to provide an explicit length" } */
533 z += memcmp (x, y1, sizeof (y1)); /* { dg-warning "call is the same expression as the second source; did you mean to provide an explicit length" } */
534 z += memcmp (x, y2, sizeof (y2)); /* { dg-warning "call is the same expression as the second source; did you mean to provide an explicit length" } */
535 z += memcmp (x, &c, sizeof (&c)); /* { dg-warning "call is the same expression as the second source; did you mean to remove the addressof" } */
536 z += memcmp (x, w, sizeof w); /* { dg-warning "call is the same expression as the second source; did you mean to dereference it" } */
538 /* These are correct, no warning. */
539 memset (y, 0, sizeof (*y));
540 memset (y1, 0, sizeof (*y2));
541 memset (buf1, 0, sizeof buf1);
542 memset (buf3, 0, sizeof (buf3));
543 memset (&buf3[0], 0, sizeof (buf3));
544 memset (&buf4[0], 0, sizeof (buf4));
545 memset (w, 0, sizeof (X));
546 /* These are probably broken, but obfuscated, no warning. */
547 memset ((void *) y, 0, sizeof (y));
548 memset ((char *) y1, 0, sizeof (y2));
549 memset (y, 0, sizeof (y) + 0);
550 memset (y1, 0, 0 + sizeof (y2));
551 memset ((void *) &c, 0, sizeof (&c));
552 memset ((signed char *) &c, 0, sizeof (&c));
553 memset (&c, 0, sizeof (&c) + 0);
554 memset (&c, 0, 0 + sizeof (&c));
556 /* These are correct, no warning. */
557 memcpy (y, x, sizeof (*y));
558 memcpy (y1, x, sizeof (*y2));
559 memcpy (buf1, x, sizeof buf1);
560 memcpy (buf3, x, sizeof (buf3));
561 memcpy (&buf3[0], x, sizeof (buf3));
562 memcpy (&buf4[0], x, sizeof (buf4));
563 memcpy (&y3, y, sizeof (y3));
564 memcpy ((char *) &y3, y, sizeof (y3));
565 memcpy (w, x, sizeof (X));
566 /* These are probably broken, but obfuscated, no warning. */
567 memcpy ((void *) y, x, sizeof (y));
568 memcpy ((char *) y1, x, sizeof (y2));
569 memcpy (y, x, sizeof (y) + 0);
570 memcpy (y1, x, 0 + sizeof (y2));
571 memcpy ((void *) &c, x, sizeof (&c));
572 memcpy ((signed char *) &c, x, sizeof (&c));
573 memcpy (&c, x, sizeof (&c) + 0);
574 memcpy (&c, x, 0 + sizeof (&c));
576 /* These are correct, no warning. */
577 memcpy (x, y, sizeof (*y));
578 memcpy (x, y1, sizeof (*y2));
579 memcpy (x, buf1, sizeof buf1);
580 memcpy (x, buf3, sizeof (buf3));
581 memcpy (x, &buf3[0], sizeof (buf3));
582 memcpy (x, &buf4[0], sizeof (buf4));
583 memcpy (y, &y3, sizeof (y3));
584 memcpy (y, (char *) &y3, sizeof (y3));
585 memcpy (x, w, sizeof (X));
586 /* These are probably broken, but obfuscated, no warning. */
587 memcpy (x, (void *) y, sizeof (y));
588 memcpy (x, (char *) y1, sizeof (y2));
589 memcpy (x, y, sizeof (y) + 0);
590 memcpy (x, y1, 0 + sizeof (y2));
591 memcpy (x, (void *) &c, sizeof (&c));
592 memcpy (x, (signed char *) &c, sizeof (&c));
593 memcpy (x, &c, sizeof (&c) + 0);
594 memcpy (x, &c, 0 + sizeof (&c));
596 /* These are correct, no warning. */
597 memmove (y, x, sizeof (*y));
598 memmove (y1, x, sizeof (*y2));
599 memmove (buf1, x, sizeof buf1);
600 memmove (buf3, x, sizeof (buf3));
601 memmove (&buf3[0], x, sizeof (buf3));
602 memmove (&buf4[0], x, sizeof (buf4));
603 memmove (&y3, y, sizeof (y3));
604 memmove ((char *) &y3, y, sizeof (y3));
605 memmove (w, x, sizeof (X));
606 /* These are probably broken, but obfuscated, no warning. */
607 memmove ((void *) y, x, sizeof (y));
608 memmove ((char *) y1, x, sizeof (y2));
609 memmove (y, x, sizeof (y) + 0);
610 memmove (y1, x, 0 + sizeof (y2));
611 memmove ((void *) &c, x, sizeof (&c));
612 memmove ((signed char *) &c, x, sizeof (&c));
613 memmove (&c, x, sizeof (&c) + 0);
614 memmove (&c, x, 0 + sizeof (&c));
616 /* These are correct, no warning. */
617 memmove (x, y, sizeof (*y));
618 memmove (x, y1, sizeof (*y2));
619 memmove (x, buf1, sizeof buf1);
620 memmove (x, buf3, sizeof (buf3));
621 memmove (x, &buf3[0], sizeof (buf3));
622 memmove (x, &buf4[0], sizeof (buf4));
623 memmove (y, &y3, sizeof (y3));
624 memmove (y, (char *) &y3, sizeof (y3));
625 memmove (x, w, sizeof (X));
626 /* These are probably broken, but obfuscated, no warning. */
627 memmove (x, (void *) y, sizeof (y));
628 memmove (x, (char *) y1, sizeof (y2));
629 memmove (x, y, sizeof (y) + 0);
630 memmove (x, y1, 0 + sizeof (y2));
631 memmove (x, (void *) &c, sizeof (&c));
632 memmove (x, (signed char *) &c, sizeof (&c));
633 memmove (x, &c, sizeof (&c) + 0);
634 memmove (x, &c, 0 + sizeof (&c));
636 /* These are correct, no warning. */
637 z += memcmp (y, x, sizeof (*y));
638 z += memcmp (y1, x, sizeof (*y2));
639 z += memcmp (buf1, x, sizeof buf1);
640 z += memcmp (buf3, x, sizeof (buf3));
641 z += memcmp (&buf3[0], x, sizeof (buf3));
642 z += memcmp (&buf4[0], x, sizeof (buf4));
643 z += memcmp (&y3, y, sizeof (y3));
644 z += memcmp ((char *) &y3, y, sizeof (y3));
645 z += memcmp (w, x, sizeof (X));
646 /* These are probably broken, but obfuscated, no warning. */
647 z += memcmp ((void *) y, x, sizeof (y));
648 z += memcmp ((char *) y1, x, sizeof (y2));
649 z += memcmp (y, x, sizeof (y) + 0);
650 z += memcmp (y1, x, 0 + sizeof (y2));
651 z += memcmp ((void *) &c, x, sizeof (&c));
652 z += memcmp ((signed char *) &c, x, sizeof (&c));
653 z += memcmp (&c, x, sizeof (&c) + 0);
654 z += memcmp (&c, x, 0 + sizeof (&c));
656 /* These are correct, no warning. */
657 z += memcmp (x, y, sizeof (*y));
658 z += memcmp (x, y1, sizeof (*y2));
659 z += memcmp (x, buf1, sizeof buf1);
660 z += memcmp (x, buf3, sizeof (buf3));
661 z += memcmp (x, &buf3[0], sizeof (buf3));
662 z += memcmp (x, &buf4[0], sizeof (buf4));
663 z += memcmp (y, &y3, sizeof (y3));
664 z += memcmp (y, (char *) &y3, sizeof (y3));
665 z += memcmp (x, w, sizeof (X));
666 /* These are probably broken, but obfuscated, no warning. */
667 z += memcmp (x, (void *) y, sizeof (y));
668 z += memcmp (x, (char *) y1, sizeof (y2));
669 z += memcmp (x, y, sizeof (y) + 0);
670 z += memcmp (x, y1, 0 + sizeof (y2));
671 z += memcmp (x, (void *) &c, sizeof (&c));
672 z += memcmp (x, (signed char *) &c, sizeof (&c));
673 z += memcmp (x, &c, sizeof (&c) + 0);
674 z += memcmp (x, &c, 0 + sizeof (&c));
676 return z;
680 f4 (char *x, char **y, int z, char w[64])
682 const char *s1 = "foobarbaz";
683 const char *s2 = "abcde12345678";
684 strncpy (x, s1, sizeof (s1)); /* { dg-warning "call is the same expression as the source; did you mean to provide an explicit length" } */
685 strncat (x, s2, sizeof (s2)); /* { dg-warning "call is the same expression as the source; did you mean to provide an explicit length" } */
686 stpncpy (x, s1, sizeof (s1)); /* { dg-warning "call is the same expression as the source; did you mean to provide an explicit length" } */
687 y[0] = strndup (s1, sizeof (s1)); /* { dg-warning "call is the same expression as the source; did you mean to provide an explicit length" } */
688 z += strncmp (s1, s2, sizeof (s1)); /* { dg-warning "call is the same expression as the first source; did you mean to provide an explicit length" } */
689 z += strncmp (s1, s2, sizeof (s2)); /* { dg-warning "call is the same expression as the second source; did you mean to provide an explicit length" } */
690 z += strncasecmp (s1, s2, sizeof (s1)); /* { dg-warning "call is the same expression as the first source; did you mean to provide an explicit length" } */
691 z += strncasecmp (s1, s2, sizeof (s2)); /* { dg-warning "call is the same expression as the second source; did you mean to provide an explicit length" } */
693 strncpy (w, s1, sizeof (w)); /* { dg-warning "call is the same expression as the destination; did you mean to provide an explicit length" } */
694 strncat (w, s2, sizeof (w)); /* { dg-warning "call is the same expression as the destination; did you mean to provide an explicit length" } */
695 stpncpy (w, s1, sizeof (w)); /* { dg-warning "call is the same expression as the destination; did you mean to provide an explicit length" } */
697 /* These are correct, no warning. */
698 const char s3[] = "foobarbaz";
699 const char s4[] = "abcde12345678";
700 strncpy (x, s3, sizeof (s3));
701 strncat (x, s4, sizeof (s4));
702 stpncpy (x, s3, sizeof (s3));
703 y[1] = strndup (s3, sizeof (s3));
704 z += strncmp (s3, s4, sizeof (s3));
705 z += strncmp (s3, s4, sizeof (s4));
706 z += strncasecmp (s3, s4, sizeof (s3));
707 z += strncasecmp (s3, s4, sizeof (s4));
709 return z;
712 /* { dg-prune-output "\[\n\r\]*will always overflow\[\n\r\]*" } */