annotate gcc/testsuite/gcc.dg/torture/Wsizeof-pointer-memaccess1.c @ 131:84e7813d76e9

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