(root)/
gcc-13.2.0/
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-require-effective-target trampolines } */
       6  /* { dg-options "-O2" } */
       7  
       8  /* This used to fail on various versions of Solaris 2 because the
       9     trampoline couldn't be made executable.  */
      10  
      11  extern void abort(void);
      12  extern double fabs(double);
      13  
      14  void foo (void)
      15  {
      16    const int correct[1100] = {1, 0, -2, 0, 1, 0, 1, -1, -10, -30, -67};
      17    int i;
      18  
      19    double x1 (void) {return 1; }
      20    double x2 (void) {return -1;}
      21    double x3 (void) {return -1;}
      22    double x4 (void) {return 1; }
      23    double x5 (void) {return 0; }
      24  
      25    typedef double pfun(void);
      26  
      27    double a (int k, pfun x1, pfun x2, pfun x3, pfun x4, pfun x5)
      28    {
      29      double b (void)
      30      {
      31        k = k - 1;
      32        return a (k, b, x1, x2, x3, x4 );
      33      }
      34  
      35      if (k <= 0)
      36        return x4 () + x5 ();
      37      else
      38        return b ();
      39    }
      40  
      41    for (i=0; i<=10; i++)
      42    {
      43      if (fabs(a( i, x1, x2, x3, x4, x5 ) - correct [i]) > 0.1)
      44        abort();
      45    }
      46  }
      47  
      48  int main (void)
      49  {
      50    foo ();
      51    return 0;
      52  }