diff options
Diffstat (limited to 'test/ARCMT/checking.m')
-rw-r--r-- | test/ARCMT/checking.m | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/test/ARCMT/checking.m b/test/ARCMT/checking.m index cf71611..3ad911e 100644 --- a/test/ARCMT/checking.m +++ b/test/ARCMT/checking.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -arcmt-check -verify -triple x86_64-apple-darwin10 %s +// RUN: %clang_cc1 -arcmt-check -verify -triple x86_64-apple-darwin10 -fblocks -Werror %s // DISABLE: mingw32 #if __has_feature(objc_arc) @@ -45,9 +45,9 @@ struct UnsafeS { }; @interface A : NSObject -- (id)retain; -- (id)retainCount; -- (id)autorelease; +- (id)retain; // expected-note {{declaration has been explicitly marked unavailable here}} +- (id)retainCount; // expected-note {{declaration has been explicitly marked unavailable here}} +- (id)autorelease; // expected-note 2 {{declaration has been explicitly marked unavailable here}} - (id)init; - (oneway void)release; - (void)dealloc; @@ -79,7 +79,8 @@ void test1(A *a, BOOL b, struct UnsafeS *unsafeS) { [a.delegate release]; // expected-error {{it is not safe to remove 'retain' message on the result of a 'delegate' message; the object that was passed to 'setDelegate:' may not be properly retained}} \ // expected-error {{ARC forbids explicit message send}} [unsafeS->unsafeObj retain]; // expected-error {{it is not safe to remove 'retain' message on an __unsafe_unretained type}} \ - // expected-error {{ARC forbids explicit message send}} + // expected-error {{ARC forbids explicit message send}} \ + // expected-error {{'retain' is unavailable}} id foo = [unsafeS->unsafeObj retain]; // no warning. [global_foo retain]; // expected-error {{it is not safe to remove 'retain' message on a global variable}} \ // expected-error {{ARC forbids explicit message send}} @@ -87,10 +88,16 @@ void test1(A *a, BOOL b, struct UnsafeS *unsafeS) { // expected-error {{ARC forbids explicit message send}} [a dealloc]; [a retain]; - [a retainCount]; // expected-error {{ARC forbids explicit message send of 'retainCount'}} + [a retainCount]; // expected-error {{ARC forbids explicit message send of 'retainCount'}} \ + // expected-error {{'retainCount' is unavailable}} [a release]; [a autorelease]; // expected-error {{it is not safe to remove an unused 'autorelease' message; its receiver may be destroyed immediately}} \ - // expected-error {{ARC forbids explicit message send}} + // expected-error {{ARC forbids explicit message send}} \ + // expected-error {{'autorelease' is unavailable}} + [a autorelease]; // expected-error {{it is not safe to remove an unused 'autorelease' message; its receiver may be destroyed immediately}} \ + // expected-error {{ARC forbids explicit message send}} \ + // expected-error {{'autorelease' is unavailable}} + a = 0; CFStringRef cfstr; NSString *str = (NSString *)cfstr; // expected-error {{cast of C pointer type 'CFStringRef' (aka 'const struct __CFString *') to Objective-C pointer type 'NSString *' requires a bridged cast}} \ @@ -135,7 +142,7 @@ void rdar8861761() { - (void) noninit { self = 0; // expected-error {{cannot assign to 'self' outside of a method in the init family}} - for (id x in collection) { // expected-error {{use of undeclared identifier 'collection'}} + for (__strong id x in collection) { // expected-error {{use of undeclared identifier 'collection'}} x = 0; } } @@ -325,3 +332,13 @@ void rdar9504750(id p) { self->x = [NSObject new]; // expected-error {{assigning retained object}} } @end + +@interface Test10 : NSObject +@property (retain) id prop; +-(void)foo; +@end + +void test(Test10 *x) { + x.prop = ^{ [x foo]; }; // expected-warning {{likely to lead to a retain cycle}} \ + // expected-note {{retained by the captured object}} +} |