OSDN Git Service

7947770dfd57d70cb9dba9c3dc20d5b43e0a213c
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.dg / 20031202-1.c
1 /* { dg-do run } */
2 /* { dg-options "-O2" } */
3 /* { dg-options "-O2 -mtune=i686" { target i?86-*-* } } */
4 /* { dg-forbid-option "-m64" { target i?86-*-* } } */
5
6 extern void abort (void);
7 extern void exit (int);
8
9 struct A { char p[6]; } __attribute__((packed));
10 struct B {
11     struct A a;
12     void * const b;
13     struct A const * const c;
14     struct A const *d;
15 };
16
17 char v;
18
19 int __attribute__((noinline))
20 foo (struct B *b)
21 {
22   int i;
23   for (i = 0; i < 6; ++i)
24     if (b->a.p[i])
25       abort ();
26   if (b->b != &v || b->c || b->d)
27     abort ();
28   return 12;
29 }
30
31 int __attribute__((noinline))
32 bar (void *x)
33 {
34   __asm __volatile ("" : "=r" (x) : "0" (x));
35   struct B y = { .b = x, .c = (void *) 0 };
36   return foo (&y) + 1;
37 }
38
39 int
40 main (void)
41 {
42   if (bar (&v) != 13)
43     abort ();
44   exit (0);
45 }