OSDN Git Service

Merge tree-ssa-20020619-branch into mainline.
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.dg / trampoline-1.c
1 /* PR target/12865 */
2 /* Origin: Waldek Hebisch <hebisch@math.uni.wroc.pl> */
3
4 /* { dg-do run } */
5 /* { dg-options "-O2" } */
6
7 /* This used to fail on various versions of Solaris 2 because the
8    trampoline couldn't be made executable.  */
9
10 extern void abort(void);
11
12 void foo (void)
13 {
14   const int correct[1100] = {1, 0, -2, 0, 1, 0, 1, -1, -10, -30, -67};
15   int i;
16
17   double x1 (void) {return 1; }
18   double x2 (void) {return -1;}
19   double x3 (void) {return -1;}
20   double x4 (void) {return 1; }
21   double x5 (void) {return 0; }
22
23   typedef double pfun(void);
24
25   double a (int k, pfun x1, pfun x2, pfun x3, pfun x4, pfun x5)
26   {
27     double b (void)
28     {
29       k = k - 1;
30       return a (k, b, x1, x2, x3, x4 );
31     }
32
33     if (k <= 0)
34       return x4 () + x5 ();
35     else
36       return b ();
37   }
38
39   for (i=0; i<=10; i++)
40   {
41     if (fabs(a( i, x1, x2, x3, x4, x5 ) - correct [i]) > 0.1)
42       abort();
43   }
44 }
45
46 int main (void)
47 {
48   foo ();
49   return 0;
50 }