1// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.core.DynamicTypeChecker -verify %s 2 3 4#define nil 0 5typedef unsigned long NSUInteger; 6typedef int BOOL; 7 8@protocol NSObject 9+ (id)alloc; 10- (id)init; 11@end 12 13@protocol NSCopying 14@end 15 16__attribute__((objc_root_class)) 17@interface NSObject <NSObject> 18@end 19 20@interface NSString : NSObject <NSCopying> 21@end 22 23@interface NSMutableString : NSString 24@end 25 26@interface NSNumber : NSObject <NSCopying> 27@end 28 29@class MyType; 30 31void testTypeCheck(NSString* str) { 32 id obj = str; 33 NSNumber *num = obj; // expected-warning {{}} 34 (void)num; 35} 36 37void testForwardDeclarations(NSString* str) { 38 id obj = str; 39 // Do not warn, since no information is available wether MyType is a sub or 40 // super class of any other type. 41 MyType *num = obj; // no warning 42 (void)num; 43} 44