1// RUN: %clang_cc1 -E %s -o %t.mm 2// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc %t.mm -o - | FileCheck %s 3// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp 4// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"Class=void*" -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp 5// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-modern-rw.cpp 6// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"Class=void*" -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-modern-rw.cpp 7 8// rdar: // 11006566 9 10void I( void (^)(void)); 11void (^noop)(void); 12 13void nothing(); 14int printf(const char*, ...); 15 16typedef void (^T) (void); 17 18void takeblock(T); 19int takeintint(int (^C)(int)) { return C(4); } 20 21T somefunction() { 22 if (^{ }) 23 nothing(); 24 25 noop = ^{}; 26 27 noop = ^{printf("\nClosure\n"); }; 28 29 I(^{ }); 30 31 return ^{printf("\nClosure\n"); }; 32} 33void test2() { 34 int x = 4; 35 36 takeblock(^{ printf("%d\n", x); }); 37 38 while (1) { 39 takeblock(^{ 40 while(1) break; // ok 41 }); 42 break; 43 } 44} 45 46void test4() { 47 void (^noop)(void) = ^{}; 48 void (*noop2)() = 0; 49} 50 51void myfunc(int (^block)(int)) {} 52 53void myfunc3(const int *x); 54 55void test5() { 56 int a; 57 58 myfunc(^(int abcd) { 59 myfunc3(&a); 60 return 1; 61 }); 62} 63 64void *X; 65 66static int global_x = 10; 67void (^global_block)(void) = ^{ printf("global x is %d\n", global_x); }; 68 69// CHECK: static __global_block_block_impl_0 __global_global_block_block_impl_0((void *)__global_block_block_func_0, &__global_block_block_desc_0_DATA); 70// CHECK: void (*global_block)(void) = (void (*)())&__global_global_block_block_impl_0; 71 72typedef void (^void_block_t)(void); 73 74static const void_block_t myBlock = ^{ }; 75 76static const void_block_t myBlock2 = ^ void(void) { }; 77