| 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 |
|
| 3 |
typedef const struct __CFString * CFStringRef; |
| 4 |
@class NSString; |
| 5 |
|
| 6 |
NSString *CFBridgingRelease(); |
| 7 |
|
| 8 |
typedef NSString * PNSString; |
| 9 |
|
| 10 |
typedef __autoreleasing NSString * AUTORELEASEPNSString; |
| 11 |
|
| 12 |
@interface I @end |
| 13 |
|
| 14 |
@implementation I |
| 15 |
- (CFStringRef)myString |
| 16 |
{ |
| 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(); // OK |
| 24 |
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 |
@end |
| 33 |
|
| 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; |
| 40 |
|
| 41 |
typedef void (^T) (); |
| 42 |
@interface NSObject @end |
| 43 |
@protocol P; |
| 44 |
@interface Radar10907090 @end |
| 45 |
|
| 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}} |
| 54 |
@end |
| 55 |
|
| 56 |
@class NSMutableDictionary, NSError; |
| 57 |
@interface Radar12280826 |
| 58 |
- (void)createInferiorTransportAndSetEnvironment:(NSMutableDictionary*)environment error:(__autoreleasing NSError*&)error; |
| 59 |
@end |
| 60 |
|
| 61 |
@implementation Radar12280826 |
| 62 |
- (void)createInferiorTransportAndSetEnvironment:(NSMutableDictionary*)environment error:(__autoreleasing NSError*&)error {} |
| 63 |
@end |
| 64 |
|