blob: 73454022ba4df78bd09beba2e2bfd2eee591f49e [file] [log] [blame]
Daniel Dunbard7d5f022009-03-24 02:24:46 +00001// RUN: clang-cc -fsyntax-only -verify -fblocks %s
Steve Naroffc0febd52008-12-10 17:49:55 +00002@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)) {
Mike Stumpaab0f7a2009-04-01 01:17:39 +000021 return bar4(objectCreationBlock);
Steve Naroffc0febd52008-12-10 17:49:55 +000022}
Douglas Gregor2a7e58d2008-12-23 00:53:59 +000023
Mike Stumpaab0f7a2009-04-01 01:17:39 +000024void bar5(id(^)(void));
25void foo5(id (^objectCreationBlock)(int)) {
26 return bar5(objectCreationBlock); // expected-warning{{incompatible block pointer types passing 'id (^)(int)', expected 'id (^)(void)'}}
27}
28
29void bar6(id(^)(int));
30void foo6(id (^objectCreationBlock)()) {
31 return bar6(objectCreationBlock); // expected-warning{{incompatible block pointer types passing 'id (^)()', expected 'id (^)(int)'}}
32}
33
Chris Lattnerbb749822009-04-11 19:17:25 +000034void foo7(id (^x)(int)) {
Douglas Gregor2a7e58d2008-12-23 00:53:59 +000035 if (x) { }
36}
Chris Lattnerbb749822009-04-11 19:17:25 +000037
38@interface itf
39@end
40
41void foo8() {
42 ^(itf x) {};
43}