Require target lra in gcc.dg/pr108095.c
[official-gcc.git] / gcc / testsuite / c-c++-common / Warray-bounds-6.c
blob5e787360314d4f19192cbcf1626e3c5474ba6ed2
1 /* PR tree-optimization/86614 - duplicate -Warray-bounds for a strncpy
2 call with out-of-bounds offset
3 { dg-do compile }
4 { dg-options "-O2 -Warray-bounds" } */
6 #if __cplusplus
7 extern "C"
8 #endif
9 char *strncpy (char *, const char *, __SIZE_TYPE__);
11 void sink (void *);
13 struct A { char b[17]; } a[2];
15 void g (const char *s, unsigned n)
17 int i = (char *)a[1].b - (char *)a + 1;
18 char *d = a[1].b;
19 /* Verify the bug is diagnosed exactly once, using either form
20 of the warning. */
21 strncpy (d + i, s, n); /* { dg-warning "array subscript \[0-9]+ is outside array bounds|offset \[0-9]+ is out of the bounds" } */
22 /* { dg-bogus "offset \[0-9]+ is out of the bounds|array subscript \[0-9]+ is outside array bounds" "" { target *-*-* } .-1 } */