xref: /minix3/external/bsd/llvm/dist/clang/test/Rewriter/rewrite-nested-blocks.mm (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc// 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*f4a2713aSLionel Sambuc// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
3*f4a2713aSLionel Sambuc// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-modern-rw.cpp
4*f4a2713aSLionel Sambuc// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"SEL=void*" -D"__declspec(X)=" %t-modern-rw.cpp
5*f4a2713aSLionel Sambuc// radar 7682149
6*f4a2713aSLionel Sambuc
7*f4a2713aSLionel Sambuc
8*f4a2713aSLionel Sambuctypedef unsigned long size_t;
9*f4a2713aSLionel Sambucvoid f(void (^block)(void));
10*f4a2713aSLionel Sambuc
11*f4a2713aSLionel Sambuc@interface X {
12*f4a2713aSLionel Sambuc	int y;
13*f4a2713aSLionel Sambuc}
14*f4a2713aSLionel Sambuc- (void)foo;
15*f4a2713aSLionel Sambuc@end
16*f4a2713aSLionel Sambuc
17*f4a2713aSLionel Sambuc@implementation X
18*f4a2713aSLionel Sambuc- (void)foo {
19*f4a2713aSLionel Sambuc    f(^{
20*f4a2713aSLionel Sambuc  f(^{
21*f4a2713aSLionel Sambuc    f(^{
22*f4a2713aSLionel Sambuc      y=42;
23*f4a2713aSLionel Sambuc    });
24*f4a2713aSLionel Sambuc  });
25*f4a2713aSLionel Sambuc});
26*f4a2713aSLionel Sambuc
27*f4a2713aSLionel Sambuc}
28*f4a2713aSLionel Sambuc@end
29*f4a2713aSLionel Sambuc
30*f4a2713aSLionel Sambucstruct S {
31*f4a2713aSLionel Sambuc  int y;
32*f4a2713aSLionel Sambuc};
33*f4a2713aSLionel Sambuc
34*f4a2713aSLionel Sambucvoid foo () {
35*f4a2713aSLionel Sambuc	struct S *SELF;
36*f4a2713aSLionel Sambuc	f(^{
37*f4a2713aSLionel Sambuc		f(^{
38*f4a2713aSLionel Sambuc			SELF->y = 42;
39*f4a2713aSLionel Sambuc		});
40*f4a2713aSLionel Sambuc	});
41*f4a2713aSLionel Sambuc}
42*f4a2713aSLionel Sambuc
43*f4a2713aSLionel Sambuc// radar 7692419
44*f4a2713aSLionel Sambuc@interface Bar
45*f4a2713aSLionel Sambuc@end
46*f4a2713aSLionel Sambuc
47*f4a2713aSLionel Sambucvoid f(Bar *);
48*f4a2713aSLionel Sambucvoid q(void (^block)(void));
49*f4a2713aSLionel Sambuc
50*f4a2713aSLionel Sambucvoid x() {
51*f4a2713aSLionel Sambuc        void (^myblock)(Bar *b) = ^(Bar *b) {
52*f4a2713aSLionel Sambuc                q(^{
53*f4a2713aSLionel Sambuc                        f(b);
54*f4a2713aSLionel Sambuc                });
55*f4a2713aSLionel Sambuc        };
56*f4a2713aSLionel Sambuc
57*f4a2713aSLionel Sambuc        Bar *b = (Bar *)42;
58*f4a2713aSLionel Sambuc        myblock(b);
59*f4a2713aSLionel Sambuc}
60