1 | // RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -analyzer-config ipa=dynamic-bifurcate -verify %s |
2 | |
3 | typedef 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 |
14 | void 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 | } |
37 | @end |
38 | |