OSDN Git Service

2011-10-18 Janus Weil <janus@gcc.gnu.org>
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.dg / pr30286.c
1 /* PR middle-end/30286 */
2 /* { dg-do run } */
3 /* { dg-options "-O2 -ftrapv" } */
4
5 extern void abort (void);
6 struct S { struct S *s; };
7 struct T { struct S *t[25]; };
8
9 void
10 __attribute__((noinline))
11 foo (int i, struct T *x, struct S *y)
12 {
13   int j;
14   for (j = 14; j > i; j--)
15     x->t[j] = y->s;
16 }
17
18 int
19 main (void)
20 {
21   struct S s;
22   struct T t;
23   int i;
24
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;
37 }