diff options
author | Carlo Zancanaro <carlo@pc-4w14-0.cs.usyd.edu.au> | 2012-10-15 17:10:06 +1100 |
---|---|---|
committer | Carlo Zancanaro <carlo@pc-4w14-0.cs.usyd.edu.au> | 2012-10-15 17:10:06 +1100 |
commit | be1de4be954c80875ad4108e0a33e8e131b2f2c0 (patch) | |
tree | 1fbbecf276bf7c7bdcbb4dd446099d6d90eaa516 /clang/test/SemaObjC/arc-jump-block.m | |
parent | c4626a62754862d20b41e8a46a3574264ea80e6d (diff) | |
parent | f1bd2e48c5324d3f7cda4090c87f8a5b6f463ce2 (diff) |
Merge branch 'master' of ssh://bitbucket.org/czan/honours
Diffstat (limited to 'clang/test/SemaObjC/arc-jump-block.m')
-rw-r--r-- | clang/test/SemaObjC/arc-jump-block.m | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/clang/test/SemaObjC/arc-jump-block.m b/clang/test/SemaObjC/arc-jump-block.m new file mode 100644 index 0000000..26a1fc8 --- /dev/null +++ b/clang/test/SemaObjC/arc-jump-block.m @@ -0,0 +1,97 @@ +// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -fobjc-arc -fblocks -verify -Wno-objc-root-class %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 + +// Test 2. rdar://problem/11150919 +int test2(id obj, int state) { // expected-note {{jump enters lifetime of block}} FIXME: wierd location + switch (state) { + case 0: + (void) ^{ (void) obj; }; + return 0; + + default: // expected-error {{switch case is in protected scope}} + return 1; + } +} + |