Anna Zaks | 54918ba | 2012-08-10 18:55:58 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -analyzer-ipa=dynamic-bifurcate -verify %s |
Anna Zaks | 3408681 | 2012-08-06 23:58:16 +0000 | [diff] [blame] | 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 | } |
Anna Zaks | acac844 | 2012-08-07 05:12:29 +0000 | [diff] [blame] | 37 | @end |