2009-12-16 04:14:24 +08:00
|
|
|
// RUN: %clang_cc1 -fsyntax-only -verify -fblocks %s
|
2011-09-28 06:38:19 +08:00
|
|
|
|
|
|
|
#define bool _Bool
|
2008-12-11 01:49:55 +08: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 09:17:39 +08:00
|
|
|
return bar4(objectCreationBlock);
|
2008-12-11 01:49:55 +08:00
|
|
|
}
|
2008-12-23 08:53:59 +08:00
|
|
|
|
2011-09-28 07:30:47 +08:00
|
|
|
void bar5(id(^)(void)); // expected-note 3{{passing argument to parameter here}}
|
2011-09-28 06:38:19 +08:00
|
|
|
void foo5(id (^objectCreationBlock)(bool)) {
|
2011-09-28 07:30:47 +08:00
|
|
|
bar5(objectCreationBlock); // expected-error {{incompatible block pointer types passing 'id (^)(bool)' to parameter of type 'id (^)(void)'}}
|
|
|
|
#undef bool
|
|
|
|
bar5(objectCreationBlock); // expected-error {{incompatible block pointer types passing 'id (^)(_Bool)' to parameter of type 'id (^)(void)'}}
|
|
|
|
#define bool int
|
|
|
|
bar5(objectCreationBlock); // expected-error {{incompatible block pointer types passing 'id (^)(_Bool)' to parameter of type 'id (^)(void)'}}
|
2009-04-01 09:17:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void bar6(id(^)(int));
|
|
|
|
void foo6(id (^objectCreationBlock)()) {
|
2009-06-08 12:24:21 +08:00
|
|
|
return bar6(objectCreationBlock);
|
2009-04-01 09:17:39 +08:00
|
|
|
}
|
|
|
|
|
2009-04-12 03:17:25 +08:00
|
|
|
void foo7(id (^x)(int)) {
|
2008-12-23 08:53:59 +08:00
|
|
|
if (x) { }
|
|
|
|
}
|
2009-04-12 03:17:25 +08:00
|
|
|
|
|
|
|
@interface itf
|
|
|
|
@end
|
|
|
|
|
|
|
|
void foo8() {
|
2011-12-15 08:38:15 +08:00
|
|
|
void *P = ^(itf x) {}; // expected-error {{interface type 'itf' cannot be passed by value; did you forget * in 'itf'}}
|
|
|
|
P = ^itf(int x) {}; // expected-error {{interface type 'itf' cannot be returned by value; did you forget * in 'itf'}}
|
|
|
|
P = ^itf() {}; // expected-error {{interface type 'itf' cannot be returned by value; did you forget * in 'itf'}}
|
|
|
|
P = ^itf{}; // expected-error {{interface type 'itf' cannot be returned by value; did you forget * in 'itf'}}
|
2009-04-12 03:17:25 +08:00
|
|
|
}
|
2009-08-15 05:53:27 +08:00
|
|
|
|
|
|
|
|
|
|
|
int foo9() {
|
|
|
|
typedef void (^DVTOperationGroupScheduler)();
|
|
|
|
id _suboperationSchedulers;
|
|
|
|
|
|
|
|
for (DVTOperationGroupScheduler scheduler in _suboperationSchedulers) {
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2010-03-10 02:34:52 +08:00
|
|
|
|
|
|
|
// rdar 7725203
|
|
|
|
@class NSString;
|
|
|
|
|
|
|
|
extern void NSLog(NSString *format, ...) __attribute__((format(__NSString__, 1, 2)));
|
|
|
|
|
|
|
|
void foo10() {
|
|
|
|
void(^myBlock)(void) = ^{
|
|
|
|
};
|
|
|
|
NSLog(@"%@", myBlock);
|
|
|
|
}
|
|
|
|
|