Fix broken MinGW build of gcc.c
[official-gcc.git] / gcc / testsuite / c-c++-common / addrtmp.c
blob3de0175e70a7eb7a050d85f6ffe36fd972c1f0b2
1 /* { dg-do compile } */
2 /* { dg-options "-O2" } */
3 /* { dg-add-options bind_pic_locally } */
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" }
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" }
15 A y[2]={{1,2},{3,4}};
16 int*h(){
17 return g(&y[1].a);
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" }
26 int*s()
28 static int i;
29 return &i;