summaryrefslogtreecommitdiffstats
path: root/test/SemaObjC/arc-retain-block-property.m
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2011-09-14 18:03:46 +0000
committerFariborz Jahanian <fjahanian@apple.com>2011-09-14 18:03:46 +0000
commit528a499eb84d61667f65b16a13780c135b822f6b (patch)
treeae1e25b0760cc673f7696ae41a8f698ee464e6c7 /test/SemaObjC/arc-retain-block-property.m
parent33e8491d7cf757812b9f8d126e0368c3ac0d2dd6 (diff)
objc-arc: warn when a 'retain' block property is
declared which does not force a 'copy' of the block literal object. // rdar://9829425 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139706 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/SemaObjC/arc-retain-block-property.m')
-rw-r--r--test/SemaObjC/arc-retain-block-property.m30
1 files changed, 30 insertions, 0 deletions
diff --git a/test/SemaObjC/arc-retain-block-property.m b/test/SemaObjC/arc-retain-block-property.m
new file mode 100644
index 0000000000..a1b181c4f7
--- /dev/null
+++ b/test/SemaObjC/arc-retain-block-property.m
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -fsyntax-only -fblocks -fobjc-arc -fobjc-nonfragile-abi -verify %s
+// rdar://9829425
+
+extern void doSomething();
+
+@interface Test
+{
+@public
+ void (^aBlock)(void);
+}
+@property (retain) void (^aBlock)(void); // expected-warning {{retain'ed block property does not copy the block - use copy attribute instead}}
+@property (weak, retain) void (^aBlockW)(void); // expected-error {{property attributes 'retain' and 'weak' are mutually exclusive}}
+@property (strong, retain) void (^aBlockS)(void); // OK
+@property (readonly, retain) void (^aBlockR)(void); // OK
+@property (copy, retain) void (^aBlockC)(void); // expected-error {{property attributes 'copy' and 'retain' are mutually exclusive}}
+@property (assign, retain) void (^aBlockA)(void); // expected-error {{property attributes 'assign' and 'retain' are mutually exclusive}}
+@end
+
+@implementation Test
+@synthesize aBlock;
+@dynamic aBlockW, aBlockS, aBlockR, aBlockC, aBlockA;
+@end
+
+int main() {
+ Test *t;
+ t.aBlock = ^{ doSomething(); };
+ t.aBlockW = ^{ doSomething(); };
+ t.aBlockS = ^{ doSomething(); };
+}
+