blob: 06b271ad4b36b35686b1570cf7a2585d932f1d1f [file] [log] [blame]
Anna Zaksbfa9ab82013-01-24 23:15:30 +00001// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -analyzer-config ipa=dynamic-bifurcate -verify %s
Anna Zaks34086812012-08-06 23:58:16 +00002
3typedef signed char BOOL;
4@protocol NSObject - (BOOL)isEqual:(id)object; @end
5@interface NSObject <NSObject> {}
6+(id)alloc;
7-(id)init;
8+(id)new;
9-(id)autorelease;
10-(id)copy;
11- (Class)class;
12-(id)retain;
13@end
14void clang_analyzer_eval(BOOL);
15
16@interface SomeOtherClass : NSObject
17- (int)getZero;
18@end
19@implementation SomeOtherClass
20- (int)getZero { return 0; }
21@end
22
23@interface MyClass : NSObject
24- (int)getZero;
25@end
26
27@implementation MyClass
28- (int)getZero { return 1; }
29
30// TODO: Not only we should correctly determine that the type of o at runtime
31// is MyClass, but we should also warn about it.
32+ (void) testCastToParent {
33 id a = [[self alloc] init];
34 SomeOtherClass *o = a;
35 clang_analyzer_eval([o getZero] == 0); // expected-warning{{FALSE}}
36}
Anna Zaksacac8442012-08-07 05:12:29 +000037@end