rdar-6600344-nil-receiver-undefined-struct-ret.m revision ef74f4c6dcd59b3af1de9d8f613c1caf3e6cb63d
1// RUN: clang -cc1 -analyze -analyzer-experimental-internal-checks -checker-cfref -analyzer-constraints=basic -analyzer-store=basic %s -verify
2// RUN: clang -cc1 -analyze -analyzer-experimental-internal-checks -checker-cfref -analyzer-constraints=basic -analyzer-store=region %s -verify
3
4typedef 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
16void createFoo() {
17  MyClass *obj = 0;  
18  Bar f = [obj foo]; // expected-warning{{The receiver of message 'foo' is nil and returns a value of type 'Bar' that will be garbage}}
19}
20
21void createFoo2() {
22  MyClass *obj = 0;  
23  [obj foo]; // no-warning
24  Bar f = [obj foo]; // expected-warning{{The receiver of message 'foo' is nil and returns a value of type 'Bar' that will be garbage}}
25}
26
27