1 /* PR middle-end/80936 - bcmp, bcopy, and bzero not declared nonnull
2 Verify that -Wnonnull is issued for calls with constant null pointers
3 with no optimization.
4 { dg-do compile }
5 { dg-options "-O0 -Wall" } */
6
7 void zero0 (void *p, unsigned n)
8 {
9 __builtin_memset (0, 0, n); // { dg-warning "\\\[-Wnonnull]" }
10 }
11
12 void zero1 (void *p, unsigned n)
13 {
14 __builtin_bzero (0, n); // { dg-warning "\\\[-Wnonnull]" }
15 }
16
17 void copy0 (void *p, const void *q, unsigned n)
18 {
19 __builtin_memcpy (0, q, n); // { dg-warning "\\\[-Wnonnull]" }
20 }
21
22 void copy1 (void *p, const void *q, unsigned n)
23 {
24 __builtin_memcpy (0, q, n); // { dg-warning "\\\[-Wnonnull]" }
25 }
26
27 void copy2 (void *p, const void *q, unsigned n)
28 {
29 __builtin_bcopy (q, 0, n); // { dg-warning "\\\[-Wnonnull]" }
30 }
31
32 void copy3 (void *p, const void *q, unsigned n)
33 {
34 __builtin_bcopy (q, 0, n); // { dg-warning "\\\[-Wnonnull]" }
35 }
36
37 int cmp0 (const void *p, const void *q, unsigned n)
38 {
39 return __builtin_memcmp (0, q, n); // { dg-warning "\\\[-Wnonnull]" }
40 }
41
42 int cmp1 (const void *p, const void *q, unsigned n)
43 {
44 return __builtin_memcmp (0, q, n); // { dg-warning "\\\[-Wnonnull]" }
45 }
46
47 int cmp2 (const void *p, const void *q, unsigned n)
48 {
49 return __builtin_bcmp (0, q, n); // { dg-warning "\\\[-Wnonnull]" }
50 }
51
52 int cmp3 (const void *p, const void *q, unsigned n)
53 {
54 return __builtin_bcmp (p, 0, n); // { dg-warning "\\\[-Wnonnull]" }
55 }