[NDS32] Add intrinsic functions for TLB operation and data prefech.
[official-gcc.git] / gcc / testsuite / gcc.dg / Warray-bounds-27.c
blob98c9439bbf358eecfeb19870e82e030ccf3cd3e1
1 /* { dg-do compile }
2 { dg-options "-O2 -Wall -Wextra -Warray-bounds -Wrestrict" } */
4 typedef __SIZE_TYPE__ size_t;
6 extern void* memcpy (void* restrict, const void* restrict, size_t);
8 extern void sink (void*, ...);
10 struct Data {
11 size_t n;
12 void *p;
15 void test_copy (void)
17 struct Data d;
18 sink (&d);
20 char dp1[sizeof d + 1];
21 char d2x[2 * sizeof d];
22 char d2xp1[2 * sizeof d + 1];
24 /* During development the following would incorrectly trigger:
25 warning: 'memcpy' forming offset [17, 25] is out of the bounds [0, 16]
26 of object ā€˜dā€™ with type 'struct Data' [-Warray-bounds]
27 that wasn't caught by the test suite. Make sure it is. */
28 memcpy (&dp1, d.p, sizeof dp1); /* { dg-bogus "\\\[-Warray-bounds" } */
30 /* Likewise. */
31 memcpy (&d2x, d.p, sizeof d2x); /* { dg-bogus "\\\[-Warray-bounds" } */
32 memcpy (&d2xp1, d.p, sizeof d2xp1); /* { dg-bogus "\\\[-Warray-bounds" } */
34 sink (&d, &dp1, &d2x, &d2xp1);