annotate clang/test/SemaObjC/arc-jump-block.m @ 207:2e18cbf3894f

LLVM12
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Tue, 08 Jun 2021 06:07:14 +0900
parents 1d019706d866
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 // RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -fobjc-arc -fblocks -verify -Wno-objc-root-class %s
anatofuz
parents:
diff changeset
2 // rdar://9535237
anatofuz
parents:
diff changeset
3
anatofuz
parents:
diff changeset
4 typedef struct dispatch_queue_s *dispatch_queue_t;
anatofuz
parents:
diff changeset
5
anatofuz
parents:
diff changeset
6 typedef void (^dispatch_block_t)(void);
anatofuz
parents:
diff changeset
7
anatofuz
parents:
diff changeset
8 void dispatch_async(dispatch_queue_t queue, dispatch_block_t block);
anatofuz
parents:
diff changeset
9
anatofuz
parents:
diff changeset
10 extern __attribute__((visibility("default"))) struct dispatch_queue_s _dispatch_main_q;
anatofuz
parents:
diff changeset
11
anatofuz
parents:
diff changeset
12 @interface SwitchBlockCrashAppDelegate
anatofuz
parents:
diff changeset
13 - (void)pageLeft;
anatofuz
parents:
diff changeset
14 - (void)pageRight;;
anatofuz
parents:
diff changeset
15 @end
anatofuz
parents:
diff changeset
16
anatofuz
parents:
diff changeset
17 @implementation SwitchBlockCrashAppDelegate
anatofuz
parents:
diff changeset
18
anatofuz
parents:
diff changeset
19 - (void)choose:(int)button {
anatofuz
parents:
diff changeset
20 switch (button) {
anatofuz
parents:
diff changeset
21 case 0:
anatofuz
parents:
diff changeset
22 dispatch_async((&_dispatch_main_q), ^{ [self pageLeft]; }); // expected-note 3 {{jump enters lifetime of block which strongly captures a variable}}
anatofuz
parents:
diff changeset
23 break;
anatofuz
parents:
diff changeset
24 case 2: // expected-error {{cannot jump}}
anatofuz
parents:
diff changeset
25 dispatch_async((&_dispatch_main_q), ^{ [self pageRight]; }); // expected-note 2 {{jump enters lifetime of block which strongly captures a variable}}
anatofuz
parents:
diff changeset
26 break;
anatofuz
parents:
diff changeset
27 case 3: // expected-error {{cannot jump}}
anatofuz
parents:
diff changeset
28 {
anatofuz
parents:
diff changeset
29 dispatch_async((&_dispatch_main_q), ^{ [self pageRight]; });
anatofuz
parents:
diff changeset
30 break;
anatofuz
parents:
diff changeset
31 }
anatofuz
parents:
diff changeset
32 case 4: // expected-error {{cannot jump}}
anatofuz
parents:
diff changeset
33 break;
anatofuz
parents:
diff changeset
34 }
anatofuz
parents:
diff changeset
35
anatofuz
parents:
diff changeset
36 __block SwitchBlockCrashAppDelegate *captured_block_obj;
anatofuz
parents:
diff changeset
37 switch (button) {
anatofuz
parents:
diff changeset
38 case 10:
anatofuz
parents:
diff changeset
39 {
anatofuz
parents:
diff changeset
40 dispatch_async((&_dispatch_main_q), ^{ [self pageLeft]; });
anatofuz
parents:
diff changeset
41 break;
anatofuz
parents:
diff changeset
42 }
anatofuz
parents:
diff changeset
43 case 12:
anatofuz
parents:
diff changeset
44 if (button)
anatofuz
parents:
diff changeset
45 dispatch_async((&_dispatch_main_q), ^{ [captured_block_obj pageRight]; });
anatofuz
parents:
diff changeset
46 break;
anatofuz
parents:
diff changeset
47 case 13:
anatofuz
parents:
diff changeset
48 while (button)
anatofuz
parents:
diff changeset
49 dispatch_async((&_dispatch_main_q), ^{ [self pageRight]; });
anatofuz
parents:
diff changeset
50 break;
anatofuz
parents:
diff changeset
51 case 14:
anatofuz
parents:
diff changeset
52 break;
anatofuz
parents:
diff changeset
53 }
anatofuz
parents:
diff changeset
54
anatofuz
parents:
diff changeset
55 switch (button) {
anatofuz
parents:
diff changeset
56 case 10:
anatofuz
parents:
diff changeset
57 {
anatofuz
parents:
diff changeset
58 dispatch_async((&_dispatch_main_q), ^{ [self pageLeft]; });
anatofuz
parents:
diff changeset
59 break;
anatofuz
parents:
diff changeset
60 }
anatofuz
parents:
diff changeset
61 case 12:
anatofuz
parents:
diff changeset
62 if (button)
anatofuz
parents:
diff changeset
63 dispatch_async((&_dispatch_main_q), ^{ [self pageRight]; });
anatofuz
parents:
diff changeset
64 switch (button) {
anatofuz
parents:
diff changeset
65 case 0:
anatofuz
parents:
diff changeset
66 {
anatofuz
parents:
diff changeset
67 dispatch_async((&_dispatch_main_q), ^{ [self pageLeft]; });
anatofuz
parents:
diff changeset
68 break;
anatofuz
parents:
diff changeset
69 }
anatofuz
parents:
diff changeset
70 case 4:
anatofuz
parents:
diff changeset
71 break;
anatofuz
parents:
diff changeset
72 }
anatofuz
parents:
diff changeset
73 break;
anatofuz
parents:
diff changeset
74 case 13:
anatofuz
parents:
diff changeset
75 while (button)
anatofuz
parents:
diff changeset
76 dispatch_async((&_dispatch_main_q), ^{ [self pageRight]; });
anatofuz
parents:
diff changeset
77 break;
anatofuz
parents:
diff changeset
78 case 14:
anatofuz
parents:
diff changeset
79 break;
anatofuz
parents:
diff changeset
80 }
anatofuz
parents:
diff changeset
81 }
anatofuz
parents:
diff changeset
82 - (void)pageLeft {}
anatofuz
parents:
diff changeset
83 - (void)pageRight {}
anatofuz
parents:
diff changeset
84 @end
anatofuz
parents:
diff changeset
85
anatofuz
parents:
diff changeset
86 // Test 2. rdar://problem/11150919
anatofuz
parents:
diff changeset
87 int test2(id obj, int state) { // expected-note {{jump enters lifetime of block}} FIXME: weird location
anatofuz
parents:
diff changeset
88 switch (state) {
anatofuz
parents:
diff changeset
89 case 0:
anatofuz
parents:
diff changeset
90 (void) ^{ (void) obj; };
anatofuz
parents:
diff changeset
91 return 0;
anatofuz
parents:
diff changeset
92
anatofuz
parents:
diff changeset
93 default: // expected-error {{cannot jump}}
anatofuz
parents:
diff changeset
94 return 1;
anatofuz
parents:
diff changeset
95 }
anatofuz
parents:
diff changeset
96 }
anatofuz
parents:
diff changeset
97