Debian Codegraph @

clang/test/Rewriter/rewrite-nested-blocks.mm

raw
1 // RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-runtime=macosx-fragile-10.5 %s -o %t-rw.cpp
2 // RUN: %clang_cc1 -fsyntax-only -std=gnu++98 -Wno-address-of-temporary -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
3 // RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-modern-rw.cpp
4 // RUN: %clang_cc1 -fsyntax-only -std=gnu++98 -Wno-address-of-temporary -D"SEL=void*" -D"__declspec(X)=" %t-modern-rw.cpp
5
6 typedef unsigned long size_t;
7 void f(void (^block)(void));
8
9 @interface X {
10 int y;
11 }
12 - (void)foo;
13 @end
14
15 @implementation X
16 - (void)foo {
17 f(^{
18 f(^{
19 f(^{
20 y=42;
21 });
22 });
23 });
24
25 }
26 @end
27
28 struct S {
29 int y;
30 };
31
32 void foo () {
33 struct S *SELF;
34 f(^{
35 f(^{
36 SELF->y = 42;
37 });
38 });
39 }
40
41 @interface Bar
42 @end
43
44 void f(Bar *);
45 void q(void (^block)(void));
46
47 void x() {
48 void (^myblock)(Bar *b) = ^(Bar *b) {
49 q(^{
50 f(b);
51 });
52 };
53
54 Bar *b = (Bar *)42;
55 myblock(b);
56 }