(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.dg/
cast-function-1.c
       1  /* PR c/12085 */
       2  /* Origin: David Hollenberg <dhollen@mosis.org> */
       3  
       4  /* Verify that the compiler doesn't inline a function at
       5     a calling point where it is viewed with a different
       6     prototype than the actual one.  */
       7  
       8  /* { dg-do compile } */
       9  /* { dg-options "-O3" } */
      10  
      11  int foo1(int);
      12  int foo2();
      13  
      14  typedef struct {
      15    double d;
      16    int a;
      17  } str_t;
      18  
      19  void bar(double d, int i, str_t s)
      20  {
      21    d = ((double (*) (int)) foo1) (i);  /* { dg-warning "8:non-compatible|abort" } */
      22    i = ((int (*) (double)) foo1) (d);  /* { dg-warning "8:non-compatible|abort" } */
      23    s = ((str_t (*) (int)) foo1) (i);   /* { dg-warning "8:non-compatible|abort" } */
      24    ((void (*) (int)) foo1) (d);        /* { dg-warning "non-compatible|abort" } */
      25    i = ((int (*) (int)) foo1) (i);     /* { dg-bogus "non-compatible|abort" } */
      26    (void) foo1 (i);                    /* { dg-bogus "non-compatible|abort" } */
      27  
      28    d = ((double (*) (int)) foo2) (i);  /* { dg-warning "8:non-compatible|abort" } */
      29    i = ((int (*) (double)) foo2) (d);  /* { dg-bogus "non-compatible|abort" } */
      30    s = ((str_t (*) (int)) foo2) (i);   /* { dg-warning "non-compatible|abort" } */
      31    ((void (*) (int)) foo2) (d);        /* { dg-warning "non-compatible|abort" } */
      32    i = ((int (*) (int)) foo2) (i);     /* { dg-bogus "non-compatible|abort" } */
      33    (void) foo2 (i);                    /* { dg-bogus "non-compatible|abort" } */
      34  }
      35  
      36  int foo1(int arg)
      37  {
      38    /* Prevent the function from becoming const and thus DCEd.  */
      39    __asm volatile ("" : "+r" (arg));
      40    return arg;
      41  }
      42  
      43  int foo2(arg)
      44    int arg;
      45  {
      46    /* Prevent the function from becoming const and thus DCEd.  */
      47    __asm volatile ("" : "+r" (arg));
      48    return arg;
      49  }