2009-03-24 05:24:46 +03:00
|
|
|
// RUN: clang-cc -fsyntax-only -verify -fblocks %s
|
2008-12-10 20:49:55 +03:00
|
|
|
@protocol NSObject;
|
|
|
|
|
|
|
|
void bar(id(^)(void));
|
|
|
|
void foo(id <NSObject>(^objectCreationBlock)(void)) {
|
|
|
|
return bar(objectCreationBlock);
|
|
|
|
}
|
|
|
|
|
|
|
|
void bar2(id(*)(void));
|
|
|
|
void foo2(id <NSObject>(*objectCreationBlock)(void)) {
|
|
|
|
return bar2(objectCreationBlock);
|
|
|
|
}
|
|
|
|
|
|
|
|
void bar3(id(*)());
|
|
|
|
void foo3(id (*objectCreationBlock)(int)) {
|
|
|
|
return bar3(objectCreationBlock);
|
|
|
|
}
|
|
|
|
|
|
|
|
void bar4(id(^)());
|
|
|
|
void foo4(id (^objectCreationBlock)(int)) {
|
2009-04-01 05:17:39 +04:00
|
|
|
return bar4(objectCreationBlock);
|
2008-12-10 20:49:55 +03:00
|
|
|
}
|
2008-12-23 03:53:59 +03:00
|
|
|
|
2009-04-01 05:17:39 +04:00
|
|
|
void bar5(id(^)(void));
|
|
|
|
void foo5(id (^objectCreationBlock)(int)) {
|
|
|
|
return bar5(objectCreationBlock); // expected-warning{{incompatible block pointer types passing 'id (^)(int)', expected 'id (^)(void)'}}
|
|
|
|
}
|
|
|
|
|
|
|
|
void bar6(id(^)(int));
|
|
|
|
void foo6(id (^objectCreationBlock)()) {
|
|
|
|
return bar6(objectCreationBlock); // expected-warning{{incompatible block pointer types passing 'id (^)()', expected 'id (^)(int)'}}
|
|
|
|
}
|
|
|
|
|
2009-04-11 23:17:25 +04:00
|
|
|
void foo7(id (^x)(int)) {
|
2008-12-23 03:53:59 +03:00
|
|
|
if (x) { }
|
|
|
|
}
|
2009-04-11 23:17:25 +04:00
|
|
|
|
|
|
|
@interface itf
|
|
|
|
@end
|
|
|
|
|
|
|
|
void foo8() {
|
2009-04-11 23:18:22 +04:00
|
|
|
void *P = ^(itf x) {}; // expected-error {{Objective-C interface type 'itf' cannot be passed by value}}
|
2009-04-11 23:17:25 +04:00
|
|
|
}
|