(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.dg/
pr81854.c
       1  /* PR c/81854 - weak alias of an incompatible symbol accepted
       2     { dg-do compile }
       3     { dg-require-ifunc "" }
       4     { dg-options "-Wextra" } */
       5  
       6  const char* __attribute__ ((weak, alias ("f0_target")))
       7  f0 (void);          /* { dg-error "alias between function and variable" } */
       8  
       9  int f0_target;      /* { dg-message "aliased declaration here" } */
      10  
      11  
      12  const char* __attribute__ ((weak, alias ("f1_target")))
      13  f1 (void);          /* { dg-warning "alias between functions of incompatible types" } */
      14  
      15  void f1_target (int *p)   /* { dg-message "aliased declaration here" } */
      16  {
      17    *p = 0;
      18  }
      19  
      20  
      21  const char* __attribute__ ((alias ("f2_target")))
      22  f2 (void*);   /* { dg-warning "alias between functions of incompatible types" } */
      23  
      24  const char* f2_target (int i)   /* { dg-message "aliased declaration here" } */
      25  {
      26    (void)&i;
      27    return 0;
      28  }
      29  
      30  int __attribute__ ((ifunc ("f3_resolver")))
      31  f3 (void);          /* { dg-message "resolver indirect function declared here" } */
      32  
      33  void* f3_resolver (void) /* { dg-warning "ifunc. resolver for .f3. should return .int \\(\\*\\)\\(void\\)." } */
      34  {
      35    return 0;
      36  }
      37  
      38  
      39  int __attribute__ ((ifunc ("f4_resolver")))
      40  f4 (void);          /* { dg-message "resolver indirect function declared here" } */
      41  
      42  typedef void F4 (void);
      43  F4* f4_resolver (void) /* { dg-warning ".ifunc. resolver for .f4. should return .int \\(\\*\\)\\(void\\)" } */
      44  {
      45    return 0;
      46  }
      47  
      48  const char* __attribute__ ((ifunc ("f5_resolver")))
      49  f5 (void);
      50  
      51  typedef const char* F5 (void);
      52  F5* f5_resolver (void)
      53  {
      54    return 0;
      55  }
      56  
      57  int __attribute__ ((ifunc ("f6_resolver")))
      58  f6 (void);          /* { dg-message "resolver indirect function declared here" } */
      59  
      60  int f6_resolver (void)   /* { dg-error ".ifunc. resolver for 'f6' must return .int \\(\\*\\)\\(void\\)." } */
      61  {
      62    return 0;
      63  }