Add test case for 'nil receiver returns undefined struct value' check.

llvm-svn: 65004
This commit is contained in:
Ted Kremenek 2009-02-19 04:07:38 +00:00
parent 66d9edc346
commit e571c4eeb7
1 changed files with 19 additions and 0 deletions

View File

@ -0,0 +1,19 @@
// RUN: clang -analyze -checker-cfref -analyzer-constraints=basic -analyzer-store=basic %s -verify
typedef struct Foo { int x; } Bar;
@interface MyClass {}
- (Bar)foo;
@end
@implementation MyClass
- (Bar)foo {
struct Foo f = { 0 };
return f;
}
@end
void createFoo() {
MyClass *obj = 0;
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.}}
}