Require target lra in gcc.dg/pr108095.c
[official-gcc.git] / gcc / testsuite / gcc.dg / Warray-bounds-57.c
blob97e9ce47bc8959de37f3dfa83ad530aca6de2f77
1 /* PR middle-end/92323 - bogus -Warray-bounds after unrolling despite
2 __builtin_unreachable
3 { dg-do compile }
4 { dg-options "-O2 -Wall" } */
6 struct S { int a[5]; } s;
8 void sink (void*);
10 #pragma GCC optimize "2"
12 void f_O2 (unsigned n, struct S *p)
14 for (unsigned i = 1; i < n - 1; ++i)
15 s.a[i - 1] = p->a[i]; // { dg-bogus "\\\[-Warray-bounds" }
17 if (n < 4 || n > 5)
18 __builtin_unreachable ();
21 void g_O2 (unsigned n, struct S *p)
23 if (n < 4 || n > 5)
24 __builtin_unreachable ();
26 for (unsigned i = 1; i < n - 1; ++i)
27 s.a[i - 1] = p->a[i];
31 // Also exercise -O3 with loop unrolling for good measure.
33 #pragma GCC optimize "3"
35 struct T { int a[6]; } t;
37 void f_O3 (unsigned n, struct T *p)
39 for (unsigned i = 1; i < n - 1; ++i)
40 t.a[i - 1] = p->a[i]; // { dg-bogus "\\\[-Warray-bounds" }
42 if (n < 5 || n > 6)
43 __builtin_unreachable ();
46 void g_O3 (unsigned n, struct T *p)
48 if (n < 5 || n > 6)
49 __builtin_unreachable ();
51 for (unsigned i = 1; i < n - 1; ++i)
52 s.a[i - 1] = p->a[i];