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 |
2 | // rdar://10244607 |
3 | |
4 | typedef const struct __CFString * CFStringRef; |
5 | @class NSString; |
6 | |
7 | NSString *CFBridgingRelease(); |
8 | |
9 | typedef NSString * PNSString; |
10 | |
11 | typedef __autoreleasing NSString * AUTORELEASEPNSString; |
12 | |
13 | @interface I @end |
14 | |
15 | @implementation I |
16 | - (CFStringRef)myString |
17 | { |
18 | CFStringRef myString = |
19 | (__bridge CFStringRef) (__strong NSString *)CFBridgingRelease(); // expected-error {{explicit ownership qualifier on cast result has no effect}} |
20 | |
21 | myString = |
22 | (__bridge CFStringRef) (__autoreleasing PNSString) CFBridgingRelease(); // expected-error {{explicit ownership qualifier on cast result has no effect}} |
23 | myString = |
24 | (__bridge CFStringRef) (AUTORELEASEPNSString) CFBridgingRelease(); // OK |
25 | myString = |
26 | (__bridge CFStringRef) (typeof(__strong NSString *)) CFBridgingRelease(); // expected-error {{explicit ownership qualifier on cast result has no effect}} |
27 | return myString; |
28 | } |
29 | |
30 | - (void)decodeValueOfObjCType:(const char *)type at:(void *)addr { |
31 | __autoreleasing id *stuff = (__autoreleasing id *)addr; |
32 | } |
33 | @end |
34 | |
35 | // rdar://problem/10711456 |
36 | __strong I *__strong test1; // expected-error {{the type 'I *__strong' is already explicitly ownership-qualified}} |
37 | __strong I *(__strong test2); // expected-error {{the type 'I *__strong' is already explicitly ownership-qualified}} |
38 | __strong I *(__strong (test3)); // expected-error {{the type 'I *__strong' is already explicitly ownership-qualified}} |
39 | __unsafe_unretained __typeof__(test3) test4; |
40 | typedef __strong I *strong_I; |
41 | __unsafe_unretained strong_I test5; |
42 | |
43 | // rdar://10907090 |
44 | typedef void (^T) (); |
45 | @interface NSObject @end |
46 | @protocol P; |
47 | @interface Radar10907090 @end |
48 | |
49 | @implementation Radar10907090 |
50 | - (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}} \ |
51 | // expected-warning {{method parameter of type '__autoreleasing id<P> &' with no explicit ownership}} |
52 | - (void) MM : (NSObject*) arg0 : (__strong NSObject**)arg : (id) arg1 : (__strong id*) arg2 {} |
53 | - (void) M : (NSObject**)arg0 : (id*)arg {} // expected-warning {{method parameter of type 'NSObject *__autoreleasing *' with no explicit ownership}} \ |
54 | // expected-warning {{method parameter of type '__autoreleasing id *' with no explicit ownership}} |
55 | - (void) N : (__strong NSObject***) arg0 : (__strong NSObject<P>***)arg : (float**) arg1 : (double) arg2 {} |
56 | - (void) BLOCK : (T&) arg0 : (T)arg : (__strong T*) arg1 {} // expected-warning {{method parameter of type '__autoreleasing T &' (aka 'void (^__autoreleasing &)()') with no explicit ownership}} |
57 | @end |
58 | |
59 | // rdar://12280826 |
60 | @class NSMutableDictionary, NSError; |
61 | @interface Radar12280826 |
62 | - (void)createInferiorTransportAndSetEnvironment:(NSMutableDictionary*)environment error:(__autoreleasing NSError*&)error; |
63 | @end |
64 | |
65 | @implementation Radar12280826 |
66 | - (void)createInferiorTransportAndSetEnvironment:(NSMutableDictionary*)environment error:(__autoreleasing NSError*&)error {} |
67 | @end |
68 | |
69 | |