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