(root)/
gcc-13.2.0/
gcc/
testsuite/
c-c++-common/
addrtmp.c
       1  /* { dg-do compile } */
       2  /* { dg-options "-O2" } */
       3  /* { dg-add-options bind_pic_locally } */
       4  
       5  typedef struct A { int a,b; } A;
       6  int*g(int*x){return x;}
       7  int*f1(){
       8    A x[2]={{1,2},{3,4}};
       9    return g(&x[1].a); // { dg-warning "returns address of local variable" }
      10  }
      11  int*f2(int n){
      12    A x[2]={{1,2},{3,4}};
      13    return n?0:g(&x[1].a); // { dg-warning "may return address of local variable" }
      14  }
      15  A y[2]={{1,2},{3,4}};
      16  int*h(){
      17    return g(&y[1].a);
      18  }
      19  int*j(int n){
      20    A x[2]={{1,2},{3,4}};
      21    int*p=g(&y[1].a);
      22    if(n==1)p=g(&x[1].a);
      23    if(n==2)p=g(&x[0].b);
      24    return p; // { dg-warning "may return address of local variable" }
      25  }
      26  int*s()
      27  {
      28    static int i;
      29    return &i;
      30  }