| 1 |
/* PR tree-optimization/83655 - ICE on an invalid call to memcpy declared |
| 2 |
with no prototype |
| 3 |
Test to verify that valid calls to common restrict-qualified built-in |
| 4 |
functions declared with no prototype are checked for overlap, and that |
| 5 |
invalid calls are ignored. |
| 6 |
{ dg-do compile } |
| 7 |
{ dg-options "-std=gnu17 -O2 -fpermissive -Wrestrict" } */ |
| 8 |
|
| 9 |
void* memcpy (); |
| 10 |
char* strncpy (); |
| 11 |
|
| 12 |
#if __cplusplus |
| 13 |
} /* extern "C" */ |
| 14 |
#endif |
| 15 |
|
| 16 |
void test_memcpy_warn (char *d) |
| 17 |
{ |
| 18 |
memcpy (d, d + 2, 3); /* { dg-warning "accessing 3 bytes at offsets 0 and 2 overlaps 1 byte at offset 2" } */ |
| 19 |
} |
| 20 |
|
| 21 |
void test_memcpy_nowarn (char *d) |
| 22 |
{ |
| 23 |
memcpy (d, d + 2, ""); |
| 24 |
} |
| 25 |
|
| 26 |
|
| 27 |
void test_strncpy_warn (char *d) |
| 28 |
{ |
| 29 |
strncpy (d + 1, d + 3, 5); /* { dg-warning "accessing 5 bytes at offsets 1 and 3 overlaps between 1 and 2 bytes at offset 3" } */ |
| 30 |
} |
| 31 |
|
| 32 |
void test_strncpy_nowarn (char *d) |
| 33 |
{ |
| 34 |
strncpy (d + 1, d + 3, ""); |
| 35 |
} |
| 36 |
|
| 37 |
/* { dg-prune-output "\\\[-Wbuiltin-declaration-mismatch]" } |
| 38 |
{ dg-prune-output "\\\[-Wint-conversion]" } */ |