blob: 9d6fe5b27d34384085fd62c5fb4ca74769817627 [file] [log] [blame]
Ted Kremenek8382cf52009-11-13 18:46:29 +00001// RUN: clang-cc -analyze -analyzer-experimental-internal-checks -checker-cfref -analyzer-constraints=basic -analyzer-store=basic %s -verify
2// RUN: clang-cc -analyze -analyzer-experimental-internal-checks -checker-cfref -analyzer-constraints=basic -analyzer-store=region %s -verify
Ted Kremenek98f1e1c2009-02-19 04:07:38 +00003
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;
Ted Kremenekfee96e02009-11-24 21:41:28 +000018 Bar f = [obj foo]; // expected-warning{{The receiver of message 'foo' is nil and returns a value of type 'Bar' that will be garbage}}
Ted Kremenek98f1e1c2009-02-19 04:07:38 +000019}
20
Ted Kremenekb930d7a2009-04-01 06:52:48 +000021void createFoo2() {
22 MyClass *obj = 0;
23 [obj foo]; // no-warning
Ted Kremenekfee96e02009-11-24 21:41:28 +000024 Bar f = [obj foo]; // expected-warning{{The receiver of message 'foo' is nil and returns a value of type 'Bar' that will be garbage}}
Ted Kremenekb930d7a2009-04-01 06:52:48 +000025}
26