blob: fe14287c7edba4434469dd49e754dd97856f2668 [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
34void foo67(id (^x)(int)) {
Douglas Gregor2a7e58d2008-12-23 00:53:59 +000035 if (x) { }
36}