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 %s
3 typedef const struct __CFString * CFStringRef;
6 NSString *CFBridgingRelease();
8 typedef NSString * PNSString;
10 typedef __autoreleasing NSString * AUTORELEASEPNSString;
15 - (CFStringRef)myString
17 CFStringRef myString =
18 (__bridge CFStringRef) (__strong NSString *)CFBridgingRelease(); // expected-error {{explicit ownership qualifier on cast result has no effect}}
21 (__bridge CFStringRef) (__autoreleasing PNSString) CFBridgingRelease(); // expected-error {{explicit ownership qualifier on cast result has no effect}}
23 (__bridge CFStringRef) (AUTORELEASEPNSString) CFBridgingRelease(); // OK
25 (__bridge CFStringRef) (typeof(__strong NSString *)) CFBridgingRelease(); // expected-error {{explicit ownership qualifier on cast result has no effect}}
29 - (void)decodeValueOfObjCType:(const char *)type at:(void *)addr {
30 __autoreleasing id *stuff = (__autoreleasing id *)addr;
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;
38 typedef __strong I *strong_I;
39 __unsafe_unretained strong_I test5;
42 @interface NSObject @end
44 @interface Radar10907090 @end
46 @implementation Radar10907090
47 - (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}}
56 @class NSMutableDictionary, NSError;
57 @interface Radar12280826
58 - (void)createInferiorTransportAndSetEnvironment:(NSMutableDictionary*)environment error:(__autoreleasing NSError*&)error;
61 @implementation Radar12280826
62 - (void)createInferiorTransportAndSetEnvironment:(NSMutableDictionary*)environment error:(__autoreleasing NSError*&)error {}