PR tree-optimization/86401
[official-gcc.git] / gcc / testsuite / c-c++-common / Warray-bounds-5.c
blobd864a47ffc8c867d531137af1aa177c5fa709245
1 /* Exercise that -Warray-bounds is handled correctly for subobjects.
2 Test case derived from the halt_fast_timekeeper function in Linux
3 kernel/time/timekeeping.c.
4 { dg-do compile }
5 { dg-options "-O2 -Warray-bounds=2 -Wno-stringop-overflow -ftrack-macro-expansion=0" } */
7 struct A
9 int i;
10 void *p;
11 int j;
14 struct B
16 struct A a;
18 int i;
21 void sink (void*);
23 static void halt_fast_timekeeper (struct B *b)
25 static struct A a;
27 struct A *pa = &b->a;
29 __builtin_memcpy (&a, pa, sizeof *pa); /* { dg-bogus "\\\[-Warray-bounds" } */
30 sink (&a);
33 struct C { int i; struct B b; } c;
35 void timekeeping_suspend (void)
37 struct B *p = &c.b;
39 halt_fast_timekeeper (p);