Ted Kremenek | cdc3a89 | 2012-08-24 20:39:55 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.core -analyzer-constraints=range -analyzer-store=region -verify -Wno-objc-root-class %s |
Andy Gibbs | 8e8fb3b | 2012-10-19 12:44:48 +0000 | [diff] [blame] | 2 | // expected-no-diagnostics |
Ted Kremenek | 98f1e1c | 2009-02-19 04:07:38 +0000 | [diff] [blame] | 3 | |
| 4 | typedef struct Foo { int x; } Bar; |
| 5 | |
| 6 | @interface MyClass {} |
| 7 | - (Bar)foo; |
| 8 | @end |
| 9 | @implementation MyClass |
| 10 | - (Bar)foo { |
| 11 | struct Foo f = { 0 }; |
| 12 | return f; |
| 13 | } |
| 14 | @end |
| 15 | |
| 16 | void createFoo() { |
| 17 | MyClass *obj = 0; |
Ted Kremenek | 4a037c7 | 2011-10-28 19:05:10 +0000 | [diff] [blame] | 18 | Bar f = [obj foo]; // no-warning |
Ted Kremenek | 98f1e1c | 2009-02-19 04:07:38 +0000 | [diff] [blame] | 19 | } |
| 20 | |
Ted Kremenek | b930d7a | 2009-04-01 06:52:48 +0000 | [diff] [blame] | 21 | void createFoo2() { |
| 22 | MyClass *obj = 0; |
| 23 | [obj foo]; // no-warning |
Ted Kremenek | 4a037c7 | 2011-10-28 19:05:10 +0000 | [diff] [blame] | 24 | Bar f = [obj foo]; // no-warning |
Ted Kremenek | b930d7a | 2009-04-01 06:52:48 +0000 | [diff] [blame] | 25 | } |
| 26 | |