Fariborz Jahanian | 918546c | 2012-08-30 23:56:02 +0000 | [diff] [blame^] | 1 | // RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -fobjc-arc -fblocks -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 -Wexplicit-ownership-type -verify -Wno-objc-root-class %s |
Fariborz Jahanian | 6d09f01 | 2011-10-28 20:06:07 +0000 | [diff] [blame] | 3 | // rdar://10244607 |
| 4 | |
| 5 | typedef const struct __CFString * CFStringRef; |
| 6 | @class NSString; |
| 7 | |
| 8 | NSString *CFBridgingRelease(); |
| 9 | |
| 10 | typedef NSString * PNSString; |
| 11 | |
| 12 | typedef __autoreleasing NSString * AUTORELEASEPNSString; |
| 13 | |
| 14 | @interface I @end |
| 15 | |
| 16 | @implementation I |
| 17 | - (CFStringRef)myString |
| 18 | { |
| 19 | CFStringRef myString = |
Fariborz Jahanian | 56892c1 | 2011-10-31 17:27:06 +0000 | [diff] [blame] | 20 | (__bridge CFStringRef) (__strong NSString *)CFBridgingRelease(); // expected-error {{explicit ownership qualifier on cast result has no effect}} |
Fariborz Jahanian | 6d09f01 | 2011-10-28 20:06:07 +0000 | [diff] [blame] | 21 | |
| 22 | myString = |
Fariborz Jahanian | 56892c1 | 2011-10-31 17:27:06 +0000 | [diff] [blame] | 23 | (__bridge CFStringRef) (__autoreleasing PNSString) CFBridgingRelease(); // expected-error {{explicit ownership qualifier on cast result has no effect}} |
Fariborz Jahanian | 6d09f01 | 2011-10-28 20:06:07 +0000 | [diff] [blame] | 24 | myString = |
| 25 | (__bridge CFStringRef) (AUTORELEASEPNSString) CFBridgingRelease(); // OK |
Fariborz Jahanian | fc2eff5 | 2011-10-29 00:06:10 +0000 | [diff] [blame] | 26 | myString = |
Fariborz Jahanian | 56892c1 | 2011-10-31 17:27:06 +0000 | [diff] [blame] | 27 | (__bridge CFStringRef) (typeof(__strong NSString *)) CFBridgingRelease(); // expected-error {{explicit ownership qualifier on cast result has no effect}} |
Fariborz Jahanian | 6d09f01 | 2011-10-28 20:06:07 +0000 | [diff] [blame] | 28 | return myString; |
| 29 | } |
| 30 | |
| 31 | - (void)decodeValueOfObjCType:(const char *)type at:(void *)addr { |
| 32 | __autoreleasing id *stuff = (__autoreleasing id *)addr; |
| 33 | } |
| 34 | @end |
John McCall | d85bf9d | 2012-02-08 00:46:41 +0000 | [diff] [blame] | 35 | |
| 36 | // rdar://problem/10711456 |
| 37 | __strong I *__strong test1; // expected-error {{the type 'I *__strong' is already explicitly ownership-qualified}} |
| 38 | __strong I *(__strong test2); // expected-error {{the type 'I *__strong' is already explicitly ownership-qualified}} |
| 39 | __strong I *(__strong (test3)); // expected-error {{the type 'I *__strong' is already explicitly ownership-qualified}} |
| 40 | __unsafe_unretained __typeof__(test3) test4; |
| 41 | typedef __strong I *strong_I; |
| 42 | __unsafe_unretained strong_I test5; |
Fariborz Jahanian | 918546c | 2012-08-30 23:56:02 +0000 | [diff] [blame^] | 43 | |
| 44 | // rdar://10907090 |
| 45 | typedef void (^T) (); |
| 46 | @interface NSObject @end |
| 47 | @protocol P; |
| 48 | @interface Radar10907090 @end |
| 49 | |
| 50 | @implementation Radar10907090 |
| 51 | - (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}} \ |
| 52 | // expected-warning {{method parameter of type '__autoreleasing id<P> *' with no explicit ownership}} |
| 53 | - (void) MM : (NSObject*) arg0 : (__strong NSObject**)arg : (id) arg1 : (__strong id*) arg2 {} |
| 54 | - (void) M : (NSObject**)arg0 : (id*)arg {} // expected-warning {{method parameter of type 'NSObject *__autoreleasing *' with no explicit ownership}} \ |
| 55 | // expected-warning {{method parameter of type '__autoreleasing id *' with no explicit ownership}} |
| 56 | - (void) N : (__strong NSObject***) arg0 : (__strong NSObject<P>***)arg : (float**) arg1 : (double) arg2 {} |
| 57 | - (void) BLOCK : (T*) arg0 : (T)arg : (__strong T*) arg1 {} // expected-warning {{method parameter of type '__autoreleasing T *' (aka 'void (^__autoreleasing *)()') with no explicit ownership}} |
| 58 | @end |