summaryrefslogtreecommitdiffstats
path: root/clang/test
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2012-03-30 05:23:48 +0000
committerJohn McCall <rjmccall@apple.com>2012-03-30 05:23:48 +0000
commit67cd5e094e431a0bed9e5d7dbf4e9c1e43a0039c (patch)
tree0e501182cbf5de4bd3a583f832a964473424f7b6 /clang/test
parent678a53c3509c3734e0a822ab4b7d73e853b5c96a (diff)
downloadbcm5719-llvm-67cd5e094e431a0bed9e5d7dbf4e9c1e43a0039c.tar.gz
bcm5719-llvm-67cd5e094e431a0bed9e5d7dbf4e9c1e43a0039c.zip
Forbid the block and lambda copy-capture of __autoreleasing variables
in ARC, under the usual reasoning limiting the use of __autoreleasing. llvm-svn: 153725
Diffstat (limited to 'clang/test')
-rw-r--r--clang/test/SemaObjC/arc-invalid.m5
-rw-r--r--clang/test/SemaObjCXX/arc-0x.mm21
2 files changed, 26 insertions, 0 deletions
diff --git a/clang/test/SemaObjC/arc-invalid.m b/clang/test/SemaObjC/arc-invalid.m
index b07460dbec4..c736ed4a167 100644
--- a/clang/test/SemaObjC/arc-invalid.m
+++ b/clang/test/SemaObjC/arc-invalid.m
@@ -11,3 +11,8 @@ void takeBlock(void (^)(void));
void test0(id p) {
takeBlock(^{ [p foo] + p; }); // expected-error {{invalid operands to binary expression}}
}
+
+void test1(void) {
+ __autoreleasing id p; // expected-note {{'p' declared here}}
+ takeBlock(^{ (void) p; }); // expected-error {{cannot capture __autoreleasing variable in a block}}
+}
diff --git a/clang/test/SemaObjCXX/arc-0x.mm b/clang/test/SemaObjCXX/arc-0x.mm
index be9f1dc2e28..28eec51775b 100644
--- a/clang/test/SemaObjCXX/arc-0x.mm
+++ b/clang/test/SemaObjCXX/arc-0x.mm
@@ -30,3 +30,24 @@ void deduction(id obj) {
} @catch (auto e) { // expected-error {{'auto' not allowed in exception declaration}}
}
}
+
+// rdar://problem/11068137
+void test1a() {
+ __autoreleasing id p; // expected-note 2 {{'p' declared here}}
+ (void) [&p] {};
+ (void) [p] {}; // expected-error {{cannot capture __autoreleasing variable in a lambda by copy}}
+ (void) [=] { (void) p; }; // expected-error {{cannot capture __autoreleasing variable in a lambda by copy}}
+}
+void test1b() {
+ __autoreleasing id v;
+ __autoreleasing id &p = v; // expected-note 2 {{'p' declared here}}
+ (void) [&p] {};
+ (void) [p] {}; // expected-error {{cannot capture __autoreleasing variable in a lambda by copy}}
+ (void) [=] { (void) p; }; // expected-error {{cannot capture __autoreleasing variable in a lambda by copy}}
+}
+void test1c() {
+ __autoreleasing id v; // expected-note {{'v' declared here}}
+ __autoreleasing id &p = v;
+ (void) ^{ (void) p; };
+ (void) ^{ (void) v; }; // expected-error {{cannot capture __autoreleasing variable in a block}}
+}
OpenPOWER on IntegriCloud