Skip analyzer strndup test on hppa*-*-hpux*
[official-gcc.git] / gcc / testsuite / gcc.dg / Warray-bounds-84.c
blobb9350d79ebf073bfb96c5e951534dc5cfde3b2b2
1 /* PR tree-optimization/101397 - spurious warning writing to the result
2 of stpcpy minus 1
3 { dg-do compile }
4 { dg-options "-O2 -Wall" } */
6 char* strcpy (char*, const char*);
8 void sink (int, ...);
10 extern char ax[], a3[3], a5[5], *s;
12 volatile int x;
14 void test_strcpy (int i)
17 char *p = strcpy (ax, s);
18 x = p[-1]; // { dg-warning "\\\[-Warray-bounds" }
19 x = p[ 0];
20 x = p[+9];
24 char *p = strcpy (a3, s);
25 x = p[-1]; // { dg-warning "\\\[-Warray-bounds" }
26 x = p[0];
27 x = p[1];
28 x = p[2];
29 x = p[3]; // { dg-warning "\\\[-Warray-bounds" }
33 char *p = strcpy (a5, s);
34 x = p[-1]; // { dg-warning "\\\[-Warray-bounds" }
35 sink (p[0], p[1], p[2], p[3], p[4]);
36 x = p[ 5]; // { dg-warning "\\\[-Warray-bounds" }
40 char *p = strcpy (a5 + 1, s);
41 x = p[-2]; // { dg-warning "\\\[-Warray-bounds" }
42 sink (p[-1], p[0], p[1], p[2], p[3]);
43 x = p[4]; // { dg-warning "\\\[-Warray-bounds" }
47 char *p = strcpy (a5 + 2, s);
48 x = p[-3]; // { dg-warning "\\\[-Warray-bounds" }
49 sink (p[-2], p[-1], p[0], p[1], p[2]);
50 x = p[3]; // { dg-warning "\\\[-Warray-bounds" }
54 char *p = strcpy (a5 + 3, s);
55 x = p[-4]; // { dg-warning "\\\[-Warray-bounds" }
56 sink (p[-3], p[-2], p[-1], p[0], p[1]);
57 x = p[2]; // { dg-warning "\\\[-Warray-bounds" }
61 char *p = strcpy (ax, a3);
62 p[-1] = 1; // { dg-warning "\\\[-Warray-bounds" }
63 sink (p[0], p[1], p[2], p[9], p[99]);