blob: 838a98b2b79d963712af7f00030eeddc2cc6c097 [file] [log] [blame]
Ted Kremenek565e4652010-02-05 02:06:54 +00001// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-constraints=basic -analyzer-store=basic %s -verify
2// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -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