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" } */
6
7 struct A
8 {
9 int i;
10 void *p;
11 int j;
12 };
13
14 struct B
15 {
16 struct A a;
17
18 int i;
19 };
20
21 void sink (void*);
22
23 static void halt_fast_timekeeper (struct B *b)
24 {
25 static struct A a;
26
27 struct A *pa = &b->a;
28
29 __builtin_memcpy (&a, pa, sizeof *pa); /* { dg-bogus "\\\[-Warray-bounds" } */
30 sink (&a);
31 }
32
33 struct C { int i; struct B b; } c;
34
35 void timekeeping_suspend (void)
36 {
37 struct B *p = &c.b;
38
39 halt_fast_timekeeper (p);
40 }