1 /* PR middle-end/63272 - GCC should warn when using pointer to dead scoped
2 variable within the same function
3 Exercise -Wdangling-pointer for VLAs.
5 { dg-options "-O0 -Wall -ftrack-macro-expansion=0" }
6 { dg-require-effective-target alloca } */
8 void sink (void*, ...);
10 void nowarn_vla (int n
)
33 void warn_one_vla (int n
)
37 int vla
[n
]; // { dg-message "'vla' declared" "pr??????" { xfail *-*-* } }
40 sink (p
); // { dg-warning "using a dangling pointer to 'vla'" "vla" { xfail *-*-* } }
44 void warn_two_vlas_same_block (int n
)
48 int vla1
[n
]; // { dg-message "'vla1' declared" "pr??????" { xfail *-*-* } }
49 int vla2
[n
]; // { dg-message "'vla2' declared" "pr??????" { xfail *-*-* } }
54 sink (p
); // { dg-warning "using a dangling pointer to 'vla1'" "vla" { xfail *-*-* } }
55 sink (q
); // { dg-warning "using a dangling pointer to 'vla2'" "vla" { xfail *-*-* } }
59 void warn_two_vlas_in_series (int n
)
63 int vla1
[n
]; // { dg-message "'vla1' declared" "pr??????" { xfail *-*-* } }
66 sink (p
); // { dg-warning "using a dangling pointer to 'vla1'" "vla" { xfail *-*-* } }
70 int vla2
[n
]; // { dg-message "'vla2' declared" "pr??????" { xfail *-*-* } }
73 sink (q
); // { dg-warning "using a dangling pointer to 'vla2'" "vla" { xfail *-*-* } }