OSDN Git Service

* gcc.dg/unused-6.c: New test.
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.dg / sibcall-5.c
1 /* Check that indirect sibcalls understand regparm.  */
2 /* { dg-do run { target i?86-*-* } } */
3 /* { dg-options "-O2" } */
4
5 int (*f)(int, int) __attribute__((regparm(2)));
6 int (*g)(int, int, int) __attribute__((regparm(3)));
7
8 int __attribute__((noinline))
9 foo(void)
10 {
11   return f(1, 2);
12 }
13
14 int __attribute__((noinline))
15 bar(void)
16 {
17   return g(1, 2, 3);
18 }
19
20 int __attribute__((regparm(2)))
21 f1(int x, int y)
22 {
23   return x*3 + y;
24 }
25
26 int __attribute__((regparm(3)))
27 g1(int x, int y, int z)
28 {
29   return x*9 + y*3 + z;
30 }
31
32 int main()
33 {
34   f = f1;
35   g = g1;
36   if (foo() != 1*3 + 2)
37     abort ();
38   if (bar() != 1*9 + 2*3 + 3)
39     abort ();
40   return 0;
41 }