summaryrefslogtreecommitdiff
path: root/test/SemaObjC/arc-jump-block.m
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2011-07-17 15:40:56 +0000
committerDimitry Andric <dim@FreeBSD.org>2011-07-17 15:40:56 +0000
commit180abc3db9ae3b4fc63cd65b15697e6ffcc8a657 (patch)
tree2097d084eb235c0b12c0bff3445f4ec7bbaa8a12 /test/SemaObjC/arc-jump-block.m
parent29cafa66ad3878dbb9f82615f19fa0bded2e443c (diff)
Notes
Diffstat (limited to 'test/SemaObjC/arc-jump-block.m')
-rw-r--r--test/SemaObjC/arc-jump-block.m84
1 files changed, 84 insertions, 0 deletions
diff --git a/test/SemaObjC/arc-jump-block.m b/test/SemaObjC/arc-jump-block.m
new file mode 100644
index 000000000000..1c7b21e4e8cd
--- /dev/null
+++ b/test/SemaObjC/arc-jump-block.m
@@ -0,0 +1,84 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fobjc-nonfragile-abi -fsyntax-only -fobjc-arc -fblocks -verify %s
+// rdar://9535237
+
+typedef struct dispatch_queue_s *dispatch_queue_t;
+
+typedef void (^dispatch_block_t)(void);
+
+void dispatch_async(dispatch_queue_t queue, dispatch_block_t block);
+
+extern __attribute__((visibility("default"))) struct dispatch_queue_s _dispatch_main_q;
+
+@interface SwitchBlockCrashAppDelegate
+- (void)pageLeft;
+- (void)pageRight;;
+@end
+
+@implementation SwitchBlockCrashAppDelegate
+
+- (void)choose:(int)button {
+ switch (button) {
+ case 0:
+ dispatch_async((&_dispatch_main_q), ^{ [self pageLeft]; }); // expected-note 3 {{jump enters lifetime of block which strongly captures a variable}}
+ break;
+ case 2: // expected-error {{switch case is in protected scope}}
+ dispatch_async((&_dispatch_main_q), ^{ [self pageRight]; }); // expected-note 2 {{jump enters lifetime of block which strongly captures a variable}}
+ break;
+ case 3: // expected-error {{switch case is in protected scope}}
+ {
+ dispatch_async((&_dispatch_main_q), ^{ [self pageRight]; });
+ break;
+ }
+ case 4: // expected-error {{switch case is in protected scope}}
+ break;
+ }
+
+ __block SwitchBlockCrashAppDelegate *captured_block_obj;
+ switch (button) {
+ case 10:
+ {
+ dispatch_async((&_dispatch_main_q), ^{ [self pageLeft]; });
+ break;
+ }
+ case 12:
+ if (button)
+ dispatch_async((&_dispatch_main_q), ^{ [captured_block_obj pageRight]; });
+ break;
+ case 13:
+ while (button)
+ dispatch_async((&_dispatch_main_q), ^{ [self pageRight]; });
+ break;
+ case 14:
+ break;
+ }
+
+ switch (button) {
+ case 10:
+ {
+ dispatch_async((&_dispatch_main_q), ^{ [self pageLeft]; });
+ break;
+ }
+ case 12:
+ if (button)
+ dispatch_async((&_dispatch_main_q), ^{ [self pageRight]; });
+ switch (button) {
+ case 0:
+ {
+ dispatch_async((&_dispatch_main_q), ^{ [self pageLeft]; });
+ break;
+ }
+ case 4:
+ break;
+ }
+ break;
+ case 13:
+ while (button)
+ dispatch_async((&_dispatch_main_q), ^{ [self pageRight]; });
+ break;
+ case 14:
+ break;
+ }
+}
+- (void)pageLeft {}
+- (void)pageRight {}
+@end