diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2014-12-11 22:56:26 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2014-12-11 22:56:26 +0000 |
commit | c9e266b8cf4abd43167b70609df6039da3ecd9b4 (patch) | |
tree | e5c73739f10329742eff12e7290b05f9263a9c33 /clang/test/SemaObjC | |
parent | b5e9b0426acff0a0c7abb16ab071d68026dd1bba (diff) | |
download | bcm5719-llvm-c9e266b8cf4abd43167b70609df6039da3ecd9b4.tar.gz bcm5719-llvm-c9e266b8cf4abd43167b70609df6039da3ecd9b4.zip |
[Objective-C]. This patch extends objc_bridge attribute to support objc_bridge(id).
This means that a pointer to the struct type to which the attribute appertains
is a CF type (and therefore an Objective-C object of some type), but not of any
specific class. rdar://19157264
llvm-svn: 224072
Diffstat (limited to 'clang/test/SemaObjC')
-rw-r--r-- | clang/test/SemaObjC/objcbridge-attribute-arc.m | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/clang/test/SemaObjC/objcbridge-attribute-arc.m b/clang/test/SemaObjC/objcbridge-attribute-arc.m index ee2bf07ed47..ab8cab8d191 100644 --- a/clang/test/SemaObjC/objcbridge-attribute-arc.m +++ b/clang/test/SemaObjC/objcbridge-attribute-arc.m @@ -221,3 +221,19 @@ void Test9(CFErrorRef2 cf, NSError *ns, NSString *str, Class c, CFUColor2Ref cf2 (void)(__bridge Class)cf; // expected-warning {{'CFErrorRef2' (aka 'struct __CFErrorRef *') bridges to NSError, not 'Class'}} (void)(__bridge CFErrorRef)c; // expected-warning {{'__unsafe_unretained Class' cannot bridge to 'CFErrorRef' (aka 'struct __CFErrorRef *')}} } + +// rdar://19157264 +#if __has_feature(objc_bridge_id) +typedef struct __attribute__((objc_bridge(id))) __CFFoo *CFFooRef; +#endif + +id convert(CFFooRef obj) { + (void)(NSError *)obj; // expected-error {{cast of C pointer type 'CFFooRef' (aka 'struct __CFFoo *') to Objective-C pointer type 'NSError *' requires a bridged cast}} \ + // expected-note {{use __bridge to convert directly (no change in ownership)}} \ + // expected-note {{use __bridge_transfer to transfer ownership of a +1 'CFFooRef' (aka 'struct __CFFoo *') into ARC}} + (void) (__bridge NSError *)obj; + (void) (id)obj; // expected-error {{cast of C pointer type 'CFFooRef' (aka 'struct __CFFoo *') to Objective-C pointer type 'id' requires a bridged cast}} \ + // expected-note {{use __bridge to convert directly (no change in ownership)}} \ + // expected-note {{use __bridge_transfer to transfer ownership of a +1 'CFFooRef' (aka 'struct __CFFoo *') into ARC}} + return (__bridge id)obj; +} |