xref: /minix3/external/bsd/llvm/dist/clang/test/Rewriter/rewrite-block-pointer.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 7638400
6*f4a2713aSLionel Sambuc
7*f4a2713aSLionel Sambuc// rdar://11375908
8*f4a2713aSLionel Sambuctypedef unsigned long size_t;
9*f4a2713aSLionel Sambuc
10*f4a2713aSLionel Sambuctypedef void * id;
11*f4a2713aSLionel Sambucvoid *sel_registerName(const char *);
12*f4a2713aSLionel Sambuc
13*f4a2713aSLionel Sambuc@interface X
14*f4a2713aSLionel Sambuc@end
15*f4a2713aSLionel Sambuc
16*f4a2713aSLionel Sambucvoid foo(void (^block)(int));
17*f4a2713aSLionel Sambuc
18*f4a2713aSLionel Sambuc@implementation X
19*f4a2713aSLionel Sambucstatic void enumerateIt(void (^block)(id, id, char *)) {
20*f4a2713aSLionel Sambuc      foo(^(int idx) { });
21*f4a2713aSLionel Sambuc}
22*f4a2713aSLionel Sambuc@end
23*f4a2713aSLionel Sambuc
24*f4a2713aSLionel Sambuc// radar 7651312
25*f4a2713aSLionel Sambucvoid apply(void (^block)(int));
26*f4a2713aSLionel Sambuc
27*f4a2713aSLionel Sambucstatic void x(int (^cmp)(int, int)) {
28*f4a2713aSLionel Sambuc	x(cmp);
29*f4a2713aSLionel Sambuc}
30*f4a2713aSLionel Sambuc
31*f4a2713aSLionel Sambucstatic void y(int (^cmp)(int, int)) {
32*f4a2713aSLionel Sambuc	apply(^(int sect) {
33*f4a2713aSLionel Sambuc		x(cmp);
34*f4a2713aSLionel Sambuc    });
35*f4a2713aSLionel Sambuc}
36*f4a2713aSLionel Sambuc
37*f4a2713aSLionel Sambuc// radar 7659483
38*f4a2713aSLionel Sambucvoid *_Block_copy(const void *aBlock);
39*f4a2713aSLionel Sambucvoid x(void (^block)(void)) {
40*f4a2713aSLionel Sambuc        block = ((__typeof(block))_Block_copy((const void *)(block)));
41*f4a2713aSLionel Sambuc}
42*f4a2713aSLionel Sambuc
43*f4a2713aSLionel Sambuc// radar 7682763
44*f4a2713aSLionel Sambuc@interface Y {
45*f4a2713aSLionel Sambuc@private
46*f4a2713aSLionel Sambuc    id _private;
47*f4a2713aSLionel Sambuc}
48*f4a2713aSLionel Sambuc- (void (^)(void))f;
49*f4a2713aSLionel Sambuc@end
50*f4a2713aSLionel Sambuc
51*f4a2713aSLionel Sambuctypedef void (^void_block_t)(void);
52*f4a2713aSLionel Sambuc
53*f4a2713aSLionel Sambuc@interface YY {
54*f4a2713aSLionel Sambuc    void_block_t __completion;
55*f4a2713aSLionel Sambuc}
56*f4a2713aSLionel Sambuc@property (copy) void_block_t f;
57*f4a2713aSLionel Sambuc@end
58*f4a2713aSLionel Sambuc
59*f4a2713aSLionel Sambuc@implementation Y
60*f4a2713aSLionel Sambuc- (void (^)(void))f {
61*f4a2713aSLionel Sambuc    return [_private f];
62*f4a2713aSLionel Sambuc}
63*f4a2713aSLionel Sambuc
64*f4a2713aSLionel Sambuc@end
65*f4a2713aSLionel Sambuc
66*f4a2713aSLionel Sambuc// rdar: //8608902
67*f4a2713aSLionel Sambuc@protocol CoreDAVAccountInfoProvider;
68*f4a2713aSLionel Sambuc@protocol CodeProvider;
69*f4a2713aSLionel Sambuctypedef void (^BDVDiscoveryCompletionHandler)(int success, id<CoreDAVAccountInfoProvider> discoveredInfo);
70*f4a2713aSLionel Sambuctypedef void (^BDVDiscoveryCompletion)(id<CodeProvider> codeInfo, int success, id<CoreDAVAccountInfoProvider> discoveredInfo);
71*f4a2713aSLionel Sambuctypedef void (^BDVDiscovery)(int success);
72*f4a2713aSLionel Sambuctypedef void (^BDVDisc)(id<CoreDAVAccountInfoProvider> discoveredInfo, id<CodeProvider> codeInfo,
73*f4a2713aSLionel Sambuc                        int success, id<CoreDAVAccountInfoProvider, CodeProvider> Info);
74*f4a2713aSLionel Sambuctypedef void (^BLOCK)(id, id<CoreDAVAccountInfoProvider>, id<CodeProvider> codeInfo);
75*f4a2713aSLionel Sambuctypedef void (^EMPTY_BLOCK)();
76*f4a2713aSLionel Sambuctypedef void (^  BDVDiscoveryCompletion1  )(id<CodeProvider> codeInfo, int success, id<CoreDAVAccountInfoProvider> discoveredInfo);
77*f4a2713aSLionel Sambuc
78*f4a2713aSLionel Sambucvoid (^BL)(void(^arg1)(), int i1, void(^arg)(int));
79*f4a2713aSLionel Sambuc
80*f4a2713aSLionel Sambuctypedef void (^iscoveryCompletionHandler)(void(^arg1)(), id<CoreDAVAccountInfoProvider> discoveredInfo);
81*f4a2713aSLionel Sambuc
82*f4a2713aSLionel Sambuctypedef void (^DVDisc)(id<CoreDAVAccountInfoProvider> discoveredInfo, id<CodeProvider> codeInfo,
83*f4a2713aSLionel Sambuc			void(^arg1)(), int i1, void(^arg)(id<CoreDAVAccountInfoProvider>),
84*f4a2713aSLionel Sambuc                        int success, id<CoreDAVAccountInfoProvider, CodeProvider> Info);
85*f4a2713aSLionel Sambuc
86*f4a2713aSLionel Sambuc
87*f4a2713aSLionel Sambuc@interface I @end
88*f4a2713aSLionel Sambuc@interface INTF @end
89*f4a2713aSLionel Sambucvoid (^BLINT)(I<CoreDAVAccountInfoProvider>* ARG, INTF<CodeProvider, CoreDAVAccountInfoProvider>* ARG1);
90*f4a2713aSLionel Sambuc
91*f4a2713aSLionel Sambucvoid  test8608902() {
92*f4a2713aSLionel Sambuc  BDVDiscoveryCompletionHandler ppp;
93*f4a2713aSLionel Sambuc  ppp(1, 0);
94*f4a2713aSLionel Sambuc}
95*f4a2713aSLionel Sambuc
96*f4a2713aSLionel Sambucvoid test9204669() {
97*f4a2713aSLionel Sambuc   __attribute__((__blocks__(byref))) char (^addChangeToData)();
98*f4a2713aSLionel Sambuc
99*f4a2713aSLionel Sambuc   addChangeToData = ^() {
100*f4a2713aSLionel Sambuc      return 'b';
101*f4a2713aSLionel Sambuc   };
102*f4a2713aSLionel Sambuc   addChangeToData();
103*f4a2713aSLionel Sambuc}
104*f4a2713aSLionel Sambuc
105*f4a2713aSLionel Sambucvoid test9204669_1() {
106*f4a2713aSLionel Sambuc   __attribute__((__blocks__(byref))) void (^addChangeToData)();
107*f4a2713aSLionel Sambuc
108*f4a2713aSLionel Sambuc   addChangeToData = ^() {
109*f4a2713aSLionel Sambuc    addChangeToData();
110*f4a2713aSLionel Sambuc   };
111*f4a2713aSLionel Sambuc}
112*f4a2713aSLionel Sambuc
113