nil-receiver-undefined-larger-than-voidptr-ret.m revision 899b3de7bc32434fc406f35255cc828ba8372b3d
1// RUN: clang-cc -analyze -checker-cfref -analyzer-constraints=basic -analyzer-store=basic %s -verify
2
3@interface MyClass {}
4- (void *)voidPtrM;
5- (int)intM;
6- (long long)longlongM;
7- (double)doubleM;
8- (long double)longDoubleM;
9@end
10@implementation MyClass
11- (void *)voidPtrM { return (void *)0; }
12- (int)intM { return 0; }
13- (long long)longlongM { return 0; }
14- (double)doubleM { return 0.0; }
15- (long double)longDoubleM { return 0.0; }
16@end
17
18void createFoo() {
19  MyClass *obj = 0;  
20  
21  void *v = [obj voidPtrM]; // no-warning
22  int i = [obj intM]; // no-warning
23}
24
25void createFoo2() {
26  MyClass *obj = 0;  
27  
28  long double ld = [obj longDoubleM]; // expected-warning{{The receiver in the message expression is 'nil' and results in the returned value}}
29}
30
31void createFoo3() {
32  MyClass *obj = 0;  
33  
34  long long ll = [obj longlongM]; // expected-warning{{The receiver in the message expression is 'nil' and results in the returned value}}
35}
36
37void createFoo4() {
38  MyClass *obj = 0;  
39  
40  double d = [obj doubleM]; // expected-warning{{The receiver in the message expression is 'nil' and results in the returned value}}
41}
42
43void createFoo5() {
44  MyClass *obj = @"";  
45  
46  double d = [obj doubleM]; // no-warning
47}
48
49