diff options
| author | Fariborz Jahanian <fjahanian@apple.com> | 2011-10-28 20:06:07 +0000 |
|---|---|---|
| committer | Fariborz Jahanian <fjahanian@apple.com> | 2011-10-28 20:06:07 +0000 |
| commit | 2fa646d5962323257a148060253b23b71543176a (patch) | |
| tree | e3b9952109ca186a1226a1b76c0f617faa3ba6e1 /clang/test | |
| parent | 104b7e3f2c0909c149bf62fc9474ecceed4d7d57 (diff) | |
| download | bcm5719-llvm-2fa646d5962323257a148060253b23b71543176a.tar.gz bcm5719-llvm-2fa646d5962323257a148060253b23b71543176a.zip | |
objective-c arc: type-casting of an objc pointer to
an rvalue retainable object type with life-time qualifier has no
effect and wil be diagnosed as error. // rdar://10244607
llvm-svn: 143219
Diffstat (limited to 'clang/test')
| -rw-r--r-- | clang/test/SemaObjC/arc-objc-lifetime.m | 32 | ||||
| -rw-r--r-- | clang/test/SemaObjC/arc-unavailable-for-weakref.m | 9 | ||||
| -rw-r--r-- | clang/test/SemaObjCXX/arc-unavailable-for-weakref.mm | 9 |
3 files changed, 44 insertions, 6 deletions
diff --git a/clang/test/SemaObjC/arc-objc-lifetime.m b/clang/test/SemaObjC/arc-objc-lifetime.m new file mode 100644 index 00000000000..19073c08c06 --- /dev/null +++ b/clang/test/SemaObjC/arc-objc-lifetime.m @@ -0,0 +1,32 @@ +// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -fobjc-arc -verify %s +// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin11 -fsyntax-only -fobjc-arc -verify %s +// rdar://10244607 + +typedef const struct __CFString * CFStringRef; +@class NSString; + +NSString *CFBridgingRelease(); + +typedef NSString * PNSString; + +typedef __autoreleasing NSString * AUTORELEASEPNSString; + +@interface I @end + +@implementation I +- (CFStringRef)myString +{ + CFStringRef myString = + (__bridge CFStringRef) (__strong NSString *)CFBridgingRelease(); // expected-error {{casting expression of type 'NSString *' to type 'NSString *__strong' with qualified lifetimewill not change object lifetime}} + + myString = + (__bridge CFStringRef) (__autoreleasing PNSString) CFBridgingRelease(); // expected-error {{casting expression of type 'NSString *' to type '__autoreleasing PNSString' (aka 'NSString *__autoreleasing') with qualified lifetimewill not change object}} + myString = + (__bridge CFStringRef) (AUTORELEASEPNSString) CFBridgingRelease(); // OK + return myString; +} + +- (void)decodeValueOfObjCType:(const char *)type at:(void *)addr { + __autoreleasing id *stuff = (__autoreleasing id *)addr; +} +@end diff --git a/clang/test/SemaObjC/arc-unavailable-for-weakref.m b/clang/test/SemaObjC/arc-unavailable-for-weakref.m index 6db2155f8c6..712ccf4a115 100644 --- a/clang/test/SemaObjC/arc-unavailable-for-weakref.m +++ b/clang/test/SemaObjC/arc-unavailable-for-weakref.m @@ -15,7 +15,8 @@ int main() { id obj; ns1 = (__weak sub *)obj; // expected-error {{assignment of a weak-unavailable object to a __weak object}} \ - // expected-error {{class is incompatible with __weak references}} + // expected-error {{class is incompatible with __weak references}} \ + // expected-error {{casting expression of type 'id' to type 'sub *__weak' with qualified lifetimewill not change object lifetime}} } // rdar://9732636 @@ -30,7 +31,8 @@ NOWEAK * Test1() { weak1 = strong1; // expected-error {{assignment of a weak-unavailable object to a __weak object}} __weak id weak2 = strong1; // expected-error {{assignment of a weak-unavailable object to a __weak object}} - return (__weak id)strong1; // expected-error {{cast of weak-unavailable object of type 'NOWEAK *' to a __weak object of type '__weak id'}} + return (__weak id)strong1; // expected-error {{cast of weak-unavailable object of type 'NOWEAK *' to a __weak object of type '__weak id'}} \ + // expected-error {{casting expression of type 'NOWEAK *' to type '__weak id' with qualified lifetimewill not change object lifetime}} } @protocol P @end @@ -42,6 +44,7 @@ NOWEAK<P, P1> * Test2() { weak1 = strong1; // expected-error {{assignment of a weak-unavailable object to a __weak object}} __weak id<P> weak2 = strong1; // expected-error {{assignment of a weak-unavailable object to a __weak object}} - return (__weak id<P>)strong1; // expected-error {{cast of weak-unavailable object of type 'NOWEAK<P,P1> *' to a __weak object of type '__weak id<P>'}} + return (__weak id<P>)strong1; // expected-error {{cast of weak-unavailable object of type 'NOWEAK<P,P1> *' to a __weak object of type '__weak id<P>'}} \ + // expected-error {{casting expression of type 'NOWEAK<P,P1> *' to type '__weak id<P>' with qualified lifetimewill not change object lifetime}} } diff --git a/clang/test/SemaObjCXX/arc-unavailable-for-weakref.mm b/clang/test/SemaObjCXX/arc-unavailable-for-weakref.mm index 24593ce5e4e..74fdd54d48e 100644 --- a/clang/test/SemaObjCXX/arc-unavailable-for-weakref.mm +++ b/clang/test/SemaObjCXX/arc-unavailable-for-weakref.mm @@ -15,7 +15,8 @@ int main() { id obj; ns1 = (__weak sub *)obj; // expected-error {{assignment of a weak-unavailable object to a __weak object}} \ - // expected-error {{class is incompatible with __weak references}} + // expected-error {{class is incompatible with __weak references}} \ + // expected-error {{casting expression of type 'id' to type 'sub *__weak' with qualified lifetimewill not change object lifetime}} } // rdar://9732636 @@ -30,7 +31,8 @@ NOWEAK * Test1() { weak1 = strong1; // expected-error {{assignment of a weak-unavailable object to a __weak object}} __weak id weak2 = strong1; // expected-error {{assignment of a weak-unavailable object to a __weak object}} - return (__weak id)strong1; // expected-error {{cast of weak-unavailable object of type 'NOWEAK *' to a __weak object of type '__weak id'}} + return (__weak id)strong1; // expected-error {{cast of weak-unavailable object of type 'NOWEAK *' to a __weak object of type '__weak id'}} \ + // expected-error {{casting expression of type 'NOWEAK *' to type '__weak id' with qualified lifetimewill not change object lifetime}} } @protocol P @end @@ -42,6 +44,7 @@ NOWEAK<P, P1> * Test2() { weak1 = strong1; // expected-error {{assignment of a weak-unavailable object to a __weak object}} __weak id<P> weak2 = strong1; // expected-error {{assignment of a weak-unavailable object to a __weak object}} - return (__weak id<P, P1>)strong1; // expected-error {{cast of weak-unavailable object of type 'NOWEAK<P,P1> *' to a __weak object of type '__weak id<P,P1>'}} + return (__weak id<P, P1>)strong1; // expected-error {{cast of weak-unavailable object of type 'NOWEAK<P,P1> *' to a __weak object of type '__weak id<P,P1>'}} \ + // expected-error {{casting expression of type 'NOWEAK<P,P1> *' to type '__weak id<P,P1>' with qualified lifetimewill not change object lifetime}} } |

