1 // RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -fobjc-arc -fblocks -verify -Wno-objc-root-class %s
3 typedef struct dispatch_queue_s *dispatch_queue_t;
5 typedef void (^dispatch_block_t)(void);
7 void dispatch_async(dispatch_queue_t queue, dispatch_block_t block);
9 extern __attribute__((visibility("default"))) struct dispatch_queue_s _dispatch_main_q;
11 @interface SwitchBlockCrashAppDelegate
16 @implementation SwitchBlockCrashAppDelegate
18 - (void)choose:(int)button {
21 dispatch_async((&_dispatch_main_q), ^{ [self pageLeft]; }); // expected-note 3 {{jump enters lifetime of block which strongly captures a variable}}
23 case 2: // expected-error {{cannot jump}}
24 dispatch_async((&_dispatch_main_q), ^{ [self pageRight]; }); // expected-note 2 {{jump enters lifetime of block which strongly captures a variable}}
26 case 3: // expected-error {{cannot jump}}
28 dispatch_async((&_dispatch_main_q), ^{ [self pageRight]; });
31 case 4: // expected-error {{cannot jump}}
35 __block SwitchBlockCrashAppDelegate *captured_block_obj;
39 dispatch_async((&_dispatch_main_q), ^{ [self pageLeft]; });
44 dispatch_async((&_dispatch_main_q), ^{ [captured_block_obj pageRight]; });
48 dispatch_async((&_dispatch_main_q), ^{ [self pageRight]; });
57 dispatch_async((&_dispatch_main_q), ^{ [self pageLeft]; });
62 dispatch_async((&_dispatch_main_q), ^{ [self pageRight]; });
66 dispatch_async((&_dispatch_main_q), ^{ [self pageLeft]; });
75 dispatch_async((&_dispatch_main_q), ^{ [self pageRight]; });
85 int test2(id obj, int state) { // expected-note {{jump enters lifetime of block}} FIXME: weird location
88 (void) ^{ (void) obj; };
91 default: // expected-error {{cannot jump}}