Ted Kremenek | 02737ed | 2008-03-31 15:02:58 +0000 | [diff] [blame^] | 1 | // RUN: clang -grsimple -verify %s |
| 2 | |
| 3 | int* f1() { |
| 4 | int x = 0; |
| 5 | return &x; // expected-warning{{Address of stack-allocated variable returned.}} expected-warning{{address of stack memory associated with local variable 'x' returned}} |
| 6 | } |
| 7 | |
| 8 | int* f2(int y) { |
| 9 | return &y; // expected-warning{{Address of stack-allocated variable returned.}} expected-warning{{address of stack memory associated with local variable 'y' returned}} |
| 10 | } |
| 11 | |
| 12 | int* 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-allocated variable returned.}} |
| 19 | } |
| 20 | |
| 21 | |