1 // RUN: %clang_cc1 -fsyntax-only -verify -fblocks %s 2 3 #define bool _Bool 4 @protocol NSObject; 5 6 void bar(id(^)(void)); 7 void foo(id <NSObject>(^objectCreationBlock)(void)) { 8 return bar(objectCreationBlock); 9 } 10 11 void bar2(id(*)(void)); 12 void foo2(id <NSObject>(*objectCreationBlock)(void)) { 13 return bar2(objectCreationBlock); 14 } 15 16 void bar3(id(*)()); 17 void foo3(id (*objectCreationBlock)(int)) { 18 return bar3(objectCreationBlock); 19 } 20 21 void bar4(id(^)()); 22 void foo4(id (^objectCreationBlock)(int)) { 23 return bar4(objectCreationBlock); 24 } 25 26 void bar5(id(^)(void)); // expected-note 3{{passing argument to parameter here}} 27 void foo5(id (^objectCreationBlock)(bool)) { 28 bar5(objectCreationBlock); // expected-error {{incompatible block pointer types passing 'id (^)(bool)' to parameter of type 'id (^)(void)'}} 29 #undef bool 30 bar5(objectCreationBlock); // expected-error {{incompatible block pointer types passing 'id (^)(_Bool)' to parameter of type 'id (^)(void)'}} 31 #define bool int 32 bar5(objectCreationBlock); // expected-error {{incompatible block pointer types passing 'id (^)(_Bool)' to parameter of type 'id (^)(void)'}} 33 } 34 35 void bar6(id(^)(int)); 36 void foo6(id (^objectCreationBlock)()) { 37 return bar6(objectCreationBlock); 38 } 39 40 void foo7(id (^x)(int)) { 41 if (x) { } 42 } 43 44 @interface itf 45 @end 46 47 void foo8() { 48 void *P = ^(itf x) {}; // expected-error {{interface type 'itf' cannot be passed by value; did you forget * in 'itf'}} 49 P = ^itf(int x) {}; // expected-error {{interface type 'itf' cannot be returned by value; did you forget * in 'itf'}} 50 P = ^itf() {}; // expected-error {{interface type 'itf' cannot be returned by value; did you forget * in 'itf'}} 51 P = ^itf{}; // expected-error {{interface type 'itf' cannot be returned by value; did you forget * in 'itf'}} 52 } 53 54 55 int foo9() { 56 typedef void (^DVTOperationGroupScheduler)(); 57 id _suboperationSchedulers; 58 59 for (DVTOperationGroupScheduler scheduler in _suboperationSchedulers) { 60 ; 61 } 62 63 } 64 65 // rdar 7725203 66 @class NSString; 67 68 extern void NSLog(NSString *format, ...) __attribute__((format(__NSString__, 1, 2))); 69 70 void foo10() { 71 void(^myBlock)(void) = ^{ 72 }; 73 NSLog(@"%@", myBlock); 74 } 75 76