blob: 36292309732b7e9b562acb705174acbee1a0f972 [file] [log] [blame]
Shih-wei Liaof8fd82b2010-02-10 11:10:31 -08001// RUN: %clang_cc1 -fsyntax-only -verify -fblocks %s
2@protocol NSObject;
3
4void bar(id(^)(void));
5void foo(id <NSObject>(^objectCreationBlock)(void)) {
6 return bar(objectCreationBlock);
7}
8
9void bar2(id(*)(void));
10void foo2(id <NSObject>(*objectCreationBlock)(void)) {
11 return bar2(objectCreationBlock);
12}
13
14void bar3(id(*)());
15void foo3(id (*objectCreationBlock)(int)) {
16 return bar3(objectCreationBlock);
17}
18
19void bar4(id(^)());
20void foo4(id (^objectCreationBlock)(int)) {
21 return bar4(objectCreationBlock);
22}
23
24void bar5(id(^)(void));
25void foo5(id (^objectCreationBlock)(int)) {
26 return bar5(objectCreationBlock); // expected-error {{incompatible block pointer types passing 'id (^)(int)', expected 'id (^)(void)'}}
27}
28
29void bar6(id(^)(int));
30void foo6(id (^objectCreationBlock)()) {
31 return bar6(objectCreationBlock);
32}
33
34void foo7(id (^x)(int)) {
35 if (x) { }
36}
37
38@interface itf
39@end
40
41void foo8() {
42 void *P = ^(itf x) {}; // expected-error {{Objective-C interface type 'itf' cannot be passed by value}}
43 P = ^itf(int x) {}; // expected-error {{Objective-C interface type 'itf' cannot be returned by value}}
44 P = ^itf() {}; // expected-error {{Objective-C interface type 'itf' cannot be returned by value}}
45 P = ^itf{}; // expected-error {{Objective-C interface type 'itf' cannot be returned by value}}
46}
47
48
49int foo9() {
50 typedef void (^DVTOperationGroupScheduler)();
51 id _suboperationSchedulers;
52
53 for (DVTOperationGroupScheduler scheduler in _suboperationSchedulers) {
54 ;
55 }
56
57}