stack-addr-ps.c revision 194aade5a0378afd1e669305fa3dc284eb4f5ec8
1// RUN: clang -checker-simple -verify %s 2 3int* f1() { 4 int x = 0; 5 return &x; // expected-warning{{Address of stack memory associated with local variable 'x' returned.}} expected-warning{{address of stack memory associated with local variable 'x' returned}} 6} 7 8int* f2(int y) { 9 return &y; // expected-warning{{Address of stack memory associated with local variable 'y' returned.}} expected-warning{{address of stack memory associated with local variable 'y' returned}} 10} 11 12int* f3(int x, int *y) { 13 int w = 0; 14 15 if (x) 16 y = &w; 17 18 return y; // expected-warning{{Address of stack memory associated with local variable 'w' returned.}} 19} 20 21unsigned short* compound_literal() { 22 return &(unsigned short){((unsigned short)0x22EF)}; // expected-warning{{Address of stack memory}} 23} 24 25