Merge from mainline.
[official-gcc.git] / gcc / testsuite / gcc.dg / 20000724-1.c
blob0516ae4611637066e2719e196613392b76e1553d
1 /* { dg-do run { target i?86-*-linux* x86_64-*-linux* } } */
2 /* { dg-options "-O2 -fomit-frame-pointer" } */
3 /* { dg-require-effective-target ilp32 } */
5 extern void abort (void);
6 extern void exit (int);
8 struct s {
9 struct { int a; } a;
10 int b;
11 struct { struct { int a; } a; struct t { struct t *a, *b; } b; } c;
14 int bar(int (*fn)(void *), void *arg, unsigned long flags)
16 return 0;
19 int baz(void *x)
21 return 0;
24 void do_check (struct s *) asm ("do_check") __attribute__((regparm(1)));
26 void __attribute__((regparm(1))) do_check(struct s *x)
28 if (x->a.a || x->b || x->c.a.a)
29 abort();
30 if (x->c.b.a != &x->c.b || x->c.b.b != &x->c.b)
31 abort();
34 #define NT "\n\t"
36 asm ("\n"
37 "___checkme:"
38 NT "pushl %eax; pushl %ebx; pushl %ecx; pushl %edx; pushl %esi; pushl %edi"
40 NT "pushl $0; pushl $0; pushl $0; pushl $0; pushl $0"
41 NT "pushl $0; pushl $0; pushl $0; pushl $0; pushl $0"
43 NT "movl %ecx, %eax"
44 NT "call do_check"
46 NT "popl %eax; popl %eax; popl %eax; popl %eax; popl %eax"
47 NT "popl %eax; popl %eax; popl %eax; popl %eax; popl %eax"
49 NT "popl %edi; popl %esi; popl %edx; popl %ecx; popl %ebx; popl %eax"
50 NT "ret"
53 extern inline void do_asm(struct s * x)
55 asm volatile("call ___checkme" : : "c" (x) : "memory");
58 int foo(void)
60 struct s x = { { 0 }, 0, { { 0 }, { &x.c.b, &x.c.b } } };
61 bar(baz, &x, 1);
62 do_asm(&x);
63 bar(baz, &x, 1);
64 do_asm(&x);
65 return 0;
68 int main()
70 foo();
71 exit(0);