Daniel Dunbar | ffd408a | 2009-03-24 02:24:46 +0000 | [diff] [blame] | 1 | // RUN: clang-cc -analyze -checker-cfref -analyzer-constraints=basic -analyzer-store=basic %s -verify |
Ted Kremenek | 72cb768 | 2009-02-19 04:07:38 +0000 | [diff] [blame] | 2 | |
| 3 | typedef struct Foo { int x; } Bar; |
| 4 | |
| 5 | @interface MyClass {} |
| 6 | - (Bar)foo; |
| 7 | @end |
| 8 | @implementation MyClass |
| 9 | - (Bar)foo { |
| 10 | struct Foo f = { 0 }; |
| 11 | return f; |
| 12 | } |
| 13 | @end |
| 14 | |
| 15 | void createFoo() { |
| 16 | MyClass *obj = 0; |
| 17 | Bar f = [obj foo]; // expected-warning{{The receiver in the message expression is 'nil' and results in the returned value (of type 'Bar') to be garbage or otherwise undefined.}} |
| 18 | } |
| 19 | |
Ted Kremenek | 7573221 | 2009-04-01 06:52:48 +0000 | [diff] [blame] | 20 | void createFoo2() { |
| 21 | MyClass *obj = 0; |
| 22 | [obj foo]; // no-warning |
| 23 | Bar f = [obj foo]; // expected-warning{{The receiver in the message expression is 'nil' and results in the returned value (of type 'Bar') to be garbage or otherwise undefined.}} |
| 24 | } |
| 25 | |