1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
/* PR 35503 - Warn about restricted pointers
Test to exercise that -Wrestrict warnings are issued for memory and
sring functions when they are declared in system headers (i.e., not
just when they are explicitly declared in the source file.)
Also verify that the warnings are issued even for calls where the
source of the aliasing violation is in a different function than
the restricted call.
{ dg-do compile }
{ dg-options "-O2 -Wrestrict" } */
#include <string.h>
void wrap_memcpy (void *d, const void *s, size_t n)
{
memcpy (d, s, n); /* { dg-warning "source argument is the same as destination" "memcpy" } */
}
void call_memcpy (void *d, size_t n)
{
const void *s = d;
wrap_memcpy (d, s, n);
}
void wrap_strcat (char *d, const char *s)
{
strcat (d, s); /* { dg-warning "source argument is the same as destination" "strcat" } */
}
void call_strcat (char *d)
{
const char *s = d;
wrap_strcat (d, s);
}
void wrap_strcpy (char *d, const char *s)
{
strcpy (d, s); /* { dg-warning "source argument is the same as destination" "strcpy" } */
}
void call_strcpy (char *d)
{
const char *s = d;
wrap_strcpy (d, s);
}
void wrap_strncat (char *d, const char *s, size_t n)
{
strncat (d, s, n); /* { dg-warning "source argument is the same as destination" "strncat" } */
}
void call_strncat (char *d, size_t n)
{
const char *s = d;
wrap_strncat (d, s, n);
}
void wrap_strncpy (char *d, const char *s, size_t n)
{
strncpy (d, s, n); /* { dg-warning "source argument is the same as destination" "strncpy" } */
}
void call_strncpy (char *d, size_t n)
{
const char *s = d;
wrap_strncpy (d, s, n);
}
|