forked from OSchip/llvm-project
Add test case for 'nil receiver returns undefined struct value' check.
llvm-svn: 65004
This commit is contained in:
parent
66d9edc346
commit
e571c4eeb7
|
@ -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.}}
|
||||
}
|
||||
|
Loading…
Reference in New Issue