brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.1 KiB · 2e0baaa Raw
65 lines · plain
1// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin11 -fsyntax-only -fobjc-arc -fblocks -Wexplicit-ownership-type -verify -Wno-objc-root-class %s2 3typedef const struct __CFString * CFStringRef;4@class NSString;5 6NSString *CFBridgingRelease();7 8typedef NSString * PNSString;9 10typedef __autoreleasing NSString * AUTORELEASEPNSString;11 12@interface I @end13 14@implementation I15- (CFStringRef)myString16{17    CFStringRef myString =18      (__bridge CFStringRef) (__strong NSString *)CFBridgingRelease(); // expected-error {{explicit ownership qualifier on cast result has no effect}}19 20    myString =21      (__bridge CFStringRef) (__autoreleasing PNSString) CFBridgingRelease(); // expected-error {{explicit ownership qualifier on cast result has no effect}}22    myString =23      (__bridge CFStringRef) (AUTORELEASEPNSString) CFBridgingRelease(); // OK24    myString =25      (__bridge CFStringRef) (typeof(__strong NSString *)) CFBridgingRelease(); // expected-error {{explicit ownership qualifier on cast result has no effect}}26    return myString;27}28 29- (void)decodeValueOfObjCType:(const char *)type at:(void *)addr {30        __autoreleasing id *stuff = (__autoreleasing id *)addr;31}32@end33 34__strong I *__strong test1; // expected-error {{the type 'I *__strong' is already explicitly ownership-qualified}}35__strong I *(__strong test2); // expected-error {{the type 'I *__strong' is already explicitly ownership-qualified}}36__strong I *(__strong (test3)); // expected-error {{the type 'I *__strong' is already explicitly ownership-qualified}}37__unsafe_unretained __typeof__(test3) test4;38typedef __strong I *strong_I;39__unsafe_unretained strong_I test5;40 41typedef void (^T) ();42@interface NSObject @end43@protocol P;44@interface Radar10907090 @end45 46@implementation Radar1090709047- (void) MMM : (NSObject*) arg0 : (NSObject<P>*&)arg : (id) arg1 : (id<P>&) arg2 {} // expected-warning {{method parameter of type 'NSObject<P> *__autoreleasing &' with no explicit ownership}} \48					// expected-warning {{method parameter of type '__autoreleasing id<P> &' with no explicit ownership}}49- (void) MM : (NSObject*) arg0 : (__strong NSObject**)arg : (id) arg1 : (__strong id*) arg2 {}50- (void) M : (NSObject**)arg0 : (id*)arg {} // expected-warning {{method parameter of type 'NSObject *__autoreleasing *' with no explicit ownership}} \51                                            // expected-warning {{method parameter of type '__autoreleasing id *' with no explicit ownership}}52- (void) N : (__strong NSObject***) arg0 : (__strong NSObject<P>***)arg : (float**) arg1 : (double) arg2 {} 53- (void) BLOCK : (T&) arg0 : (T)arg  : (__strong T*) arg1 {} // expected-warning {{method parameter of type '__autoreleasing T &' (aka 'void (^__autoreleasing &)()') with no explicit ownership}}54@end55 56@class NSMutableDictionary, NSError;57@interface Radar1228082658- (void)createInferiorTransportAndSetEnvironment:(NSMutableDictionary*)environment error:(__autoreleasing NSError*&)error;59@end60 61@implementation Radar1228082662- (void)createInferiorTransportAndSetEnvironment:(NSMutableDictionary*)environment error:(__autoreleasing NSError*&)error {}63@end64 65