Mercurial > hg > CbC > CbC_gcc
view gcc/testsuite/c-c++-common/addrtmp.c @ 158:494b0b89df80 default tip
...
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 25 May 2020 18:13:55 +0900 |
parents | 04ced10e8804 |
children |
line wrap: on
line source
/* { dg-do compile } */ /* { dg-options "-O2" } */ /* { dg-add-options bind_pic_locally } */ typedef struct A { int a,b; } A; int*g(int*x){return x;} int*f1(){ A x[2]={{1,2},{3,4}}; return g(&x[1].a); // { dg-warning "returns address of local variable" } } int*f2(int n){ A x[2]={{1,2},{3,4}}; return n?0:g(&x[1].a); // { dg-warning "may return address of local variable" } } A y[2]={{1,2},{3,4}}; int*h(){ return g(&y[1].a); } int*j(int n){ A x[2]={{1,2},{3,4}}; int*p=g(&y[1].a); if(n==1)p=g(&x[1].a); if(n==2)p=g(&x[0].b); return p; // { dg-warning "may return address of local variable" } } int*s() { static int i; return &i; }