1 // RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -fobjc-arc -fblocks -fobjc-runtime-has-weak -Wexplicit-ownership-type -verify -Wno-objc-root-class %s
2 // RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin11 -fsyntax-only -fobjc-arc -fblocks -fobjc-runtime-has-weak -Wexplicit-ownership-type -verify -Wno-objc-root-class %s
4 typedef const struct __CFString * CFStringRef;
7 NSString *CFBridgingRelease(void);
9 typedef NSString * PNSString;
11 typedef __autoreleasing NSString * AUTORELEASEPNSString;
16 - (CFStringRef)myString
18 CFStringRef myString =
19 (__bridge CFStringRef) (__strong NSString *)CFBridgingRelease(); // expected-error {{explicit ownership qualifier on cast result has no effect}}
22 (__bridge CFStringRef) (__autoreleasing PNSString) CFBridgingRelease(); // expected-error {{explicit ownership qualifier on cast result has no effect}}
24 (__bridge CFStringRef) (AUTORELEASEPNSString) CFBridgingRelease(); // OK
26 (__bridge CFStringRef) (typeof(__strong NSString *)) CFBridgingRelease(); // expected-error {{explicit ownership qualifier on cast result has no effect}}
30 - (void)decodeValueOfObjCType:(const char *)type at:(void *)addr {
31 __autoreleasing id *stuff = (__autoreleasing id *)addr;
35 __strong I *__strong test1; // expected-error {{the type 'I *__strong' is already explicitly ownership-qualified}}
36 __strong I *(__strong test2); // expected-error {{the type 'I *__strong' is already explicitly ownership-qualified}}
37 __strong I *(__strong (test3)); // expected-error {{the type 'I *__strong' is already explicitly ownership-qualified}}
38 __unsafe_unretained __typeof__(test3) test4;
39 typedef __strong I *strong_I;
40 __unsafe_unretained strong_I test5;
42 typedef void (^T) (void);
43 @interface NSObject @end
45 @interface Radar10907090 @end
47 @implementation Radar10907090
48 - (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}} \
49 // expected-warning {{method parameter of type '__autoreleasing id<P> *' with no explicit ownership}}
50 - (void) MM : (NSObject*) arg0 : (__strong NSObject**)arg : (id) arg1 : (__strong id*) arg2 {}
51 - (void) M : (NSObject**)arg0 : (id*)arg {} // expected-warning {{method parameter of type 'NSObject *__autoreleasing *' with no explicit ownership}} \
52 // expected-warning {{method parameter of type '__autoreleasing id *' with no explicit ownership}}
53 - (void) N : (__strong NSObject***) arg0 : (__strong NSObject<P>***)arg : (float**) arg1 : (double) arg2 {}
54 - (void) BLOCK : (T*) arg0 : (T)arg : (__strong T*) arg1 {} // expected-warning-re {{method parameter of type '__autoreleasing T *' (aka 'void (^__autoreleasing *)({{(void)?}})') with no explicit ownership}}
57 @class NSMutableDictionary, NSError;
58 @interface Radar12280826
59 - (void)createInferiorTransportAndSetEnvironment:(NSMutableDictionary*)environment error:(__autoreleasing NSError**)error;
62 @implementation Radar12280826
63 - (void)createInferiorTransportAndSetEnvironment:(NSMutableDictionary*)environment error:(__autoreleasing NSError**)error {}
66 typedef __strong id strong_id;
67 typedef NSObject *NSObject_ptr;
68 typedef __strong NSObject *strong_NSObject_ptr;
71 __strong id f1(void); // expected-warning{{ARC __strong lifetime qualifier on return type is ignored}}
72 NSObject __unsafe_unretained *f2(int); // expected-warning{{ARC __unsafe_unretained lifetime qualifier on return type is ignored}}
73 __autoreleasing NSObject *f3(void); // expected-warning{{ARC __autoreleasing lifetime qualifier on return type is ignored}}
74 NSObject * __strong f4(void); // expected-warning{{ARC __strong lifetime qualifier on return type is ignored}}
75 NSObject_ptr __strong f5(void); // expected-warning{{ARC __strong lifetime qualifier on return type is ignored}}
77 typedef __strong id (*fptr)(int); // expected-warning{{ARC __strong lifetime qualifier on return type is ignored}}
81 strong_NSObject_ptr f7(void);
82 typedef __strong id (^block_ptr)(int);
85 __weak id *(^myBlock)(void);
86 __weak id *var = myBlock();
87 (void) (__strong id *) &myBlock;
88 (void) (__weak id *) &myBlock; // expected-error {{cast}}
91 __weak id (^myBlock)(void);
92 (void) (__weak id *) &myBlock;
93 (void) (__strong id *) &myBlock; // expected-error {{cast}}
96 __weak id (^*(^myBlock)(void))(void);
97 (void) (__weak id*) myBlock();
98 (void) (__strong id*) myBlock(); // expected-error {{cast}}
99 (void) (__weak id*) &myBlock; // expected-error {{cast}}
100 (void) (__strong id*) &myBlock;
105 __weak Test9 **(^myBlock)(void);
106 __weak Test9 **var = myBlock();
107 (void) (__strong Test9 **) &myBlock;
108 (void) (__weak Test9 **) &myBlock; // expected-error {{cast}}
111 __weak Test9 *(^myBlock)(void);
112 (void) (__weak Test9**) &myBlock;
113 (void) (__strong Test9**) &myBlock; // expected-error {{cast}}
116 __weak Test9 *(^*(^myBlock)(void))(void);
117 (void) (__weak Test9 **) myBlock();
118 (void) (__strong Test9 **) myBlock(); // expected-error {{cast}}
119 (void) (__weak Test9 **) &myBlock; // expected-error {{cast}}
120 (void) (__strong Test9 **) &myBlock;