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