blob: 7230f21c08c37c1b8a0a383c502e2a04de6ddd84 [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;
18 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.}}
19}
20
Ted Kremenekb930d7a2009-04-01 06:52:48 +000021void createFoo2() {
22 MyClass *obj = 0;
23 [obj foo]; // no-warning
24 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.}}
25}
26