Require target lra in gcc.dg/pr108095.c
[official-gcc.git] / gcc / testsuite / gcc.dg / Wnonnull-3.c
blobad016df93319906f677eddc5490f3ad503452cc8
1 /* PR middle-end/80936 - bcmp, bcopy, and bzero not declared nonnull
2 Verify that with optimization, -Wnonnull is issued for calls with
3 non-constant arguments determined to be null.
4 { dg-do compile }
5 { dg-options "-O2 -Wall" } */
7 #define NOIPA __attribute__ ((noipa))
9 NOIPA void zero0 (void *p, unsigned n)
11 if (p == 0)
12 __builtin_memset (p, 0, n); // { dg-warning "\\\[-Wnonnull]" }
15 NOIPA void zero1 (void *p, unsigned n)
17 if (p == 0)
18 __builtin_bzero (p, n); // { dg-warning "\\\[-Wnonnull]" }
21 NOIPA void copy0 (void *p, const void *q, unsigned n)
23 if (p == 0)
24 __builtin_memcpy (p, q, n); // { dg-warning "\\\[-Wnonnull]" }
27 NOIPA void copy1 (void *p, const void *q, unsigned n)
29 if (q == 0)
30 __builtin_memcpy (p, q, n); // { dg-warning "\\\[-Wnonnull]" }
33 NOIPA void copy2 (void *p, const void *q, unsigned n)
35 if (p == 0)
36 __builtin_bcopy (q, p, n); // { dg-warning "\\\[-Wnonnull]" }
39 NOIPA void copy3 (void *p, const void *q, unsigned n)
41 if (q == 0)
42 __builtin_bcopy (q, p, n); // { dg-warning "\\\[-Wnonnull]" }
45 NOIPA int cmp0 (const void *p, const void *q, unsigned n)
47 if (p == 0)
48 return __builtin_memcmp (p, q, n); // { dg-warning "\\\[-Wnonnull]" }
49 return 0;
52 NOIPA int cmp1 (const void *p, const void *q, unsigned n)
54 if (q == 0)
55 return __builtin_memcmp (p, q, n); // { dg-warning "\\\[-Wnonnull]" }
56 return 0;
59 NOIPA int cmp2 (const void *p, const void *q, unsigned n)
61 if (p == 0)
62 return __builtin_bcmp (p, q, n); // { dg-warning "\\\[-Wnonnull]" }
63 return 0;
66 NOIPA int cmp3 (const void *p, const void *q, unsigned n)
68 if (q == 0)
69 return __builtin_bcmp (p, q, n); // { dg-warning "\\\[-Wnonnull]" }
70 return 0;