Add new test to verify that the array index, limit, and stride are
[official-gcc.git] / gcc / testsuite / gcc.dg / pr30286.c
blob9ec49b4231ada862d988a5cfc83aef563c8e6867
1 /* PR middle-end/30286 */
2 /* { dg-do run } */
3 /* { dg-options "-O2 -ftrapv" } */
5 extern void abort (void);
6 struct S { struct S *s; };
7 struct T { struct S *t[25]; };
9 void
10 __attribute__((noinline))
11 foo (int i, struct T *x, struct S *y)
13 int j;
14 for (j = 14; j > i; j--)
15 x->t[j] = y->s;
18 int
19 main (void)
21 struct S s;
22 struct T t;
23 int i;
25 s.s = &s;
26 __builtin_memset (&t, 0, sizeof (t));
27 foo (6, &t, &s);
28 for (i = 0; i < 25; i++)
29 if (t.t[i] != ((i > 6 && i <= 14) ? &s : (struct S *) 0))
30 abort ();
31 __builtin_memset (&t, 0, sizeof (t));
32 foo (-1, &t, &s);
33 for (i = 0; i < 25; i++)
34 if (t.t[i] != ((i >= 0 && i <= 14) ? &s : (struct S *) 0))
35 abort ();
36 return 0;