Add new test to verify that the array index, limit, and stride are
[official-gcc.git] / gcc / testsuite / gcc.dg / pr40946.c
blob3fd804e5632a7aaaa6ec8a871b804134b387a16b
1 /* PR middle-end/40946 */
2 /* { dg-do compile } */
3 /* { dg-options "-O2 -Wall" } */
5 struct A
7 unsigned char a1[8];
8 unsigned short a2, a3, a4, a5, a6, a7;
9 };
11 int bar (void *, const char *, int);
12 char *foo (void *, int);
14 char *
15 baz (const char *x, const char *y)
17 int a = sizeof (struct A) + 2 * (__builtin_strlen (y)
18 + __builtin_strlen (x) + 24) + 16;
19 struct A *b = __builtin_malloc (a);
20 char *c;
21 int d;
23 b->a4 = sizeof (struct A);
24 c = ((char *) b) + b->a4;
25 d = ((char *) b) + a - c;
26 b->a2 = b->a3 = (unsigned short) bar (c, y, d); /* { dg-bogus "array subscript is above array bounds" } */
27 c += b->a2;
28 d = ((char *) b) + a - c;
29 b->a7 = b->a4 + b->a2;
30 b->a5 = b->a6 = (unsigned short) bar (c, x, d);
31 c = foo (b, a);
32 return c;