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