rdar-6600344-nil-receiver-undefined-struct-ret.m revision 6f0b2ef5e1739e58197ae8d21ea1757efc2d41dc
1// RUN: clang-cc -analyze -checker-cfref -analyzer-constraints=basic -analyzer-store=basic %s -verify &&
2// RUN: clang-cc -analyze -checker-cfref -analyzer-constraints=basic -analyzer-store=basic-old-cast %s -verify &&
3// RUN: clang-cc -analyze -checker-cfref -analyzer-constraints=basic -analyzer-store=region %s -verify
4
5typedef struct Foo { int x; } Bar;
6
7@interface MyClass {}
8- (Bar)foo;
9@end
10@implementation MyClass
11- (Bar)foo { 
12  struct Foo f = { 0 };
13  return f;
14}
15@end
16
17void createFoo() {
18  MyClass *obj = 0;  
19  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.}}
20}
21
22void createFoo2() {
23  MyClass *obj = 0;  
24  [obj foo]; // no-warning
25  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.}}
26}
27
28