This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
f(b); // expected-warning {{passing 'NSArray<P2> *' to parameter of incompatible type 'id<P>'}}
}
voidtest3() {
voidtest3(void) {
f4(^(NSArray<P2>* a) { }); // expected-error {{incompatible block pointer types passing 'void (^)(NSArray<P2> *)' to parameter of type 'void (^)(id<P>)'}}
// Returned value is used outside of a block, so error on changing
// a return type to a more general than expected.
NSAllArray *(^block)(id);
Expand All
@@ -158,7 +158,7 @@ int test5() {
// explained in non-compatibility test above, it is not safe in general. But
// to keep existing code working we support a compatibility mode that uses
// previous type checking.
inttest5() {
inttest5(void) {
NSAllArray *(^block)(id);
id <Foo> (^genericBlock)(id);
genericBlock = block;
Expand All
@@ -183,7 +183,7 @@ @interface radar10798770
- (void)sortUsingComparator:(NSComparator)c;
@end
voidf() {
voidf(void) {
radar10798770 *f;
[f sortUsingComparator:^(id a, id b) {
return NSOrderedSame;
Expand All
@@ -194,41 +194,41 @@ void f() {
@protocolP1@end
@protocolP2@end
voidTest() {
void (^aBlock)();
voidTest(void) {
void (^aBlock)(void);
id anId = aBlock; // OK
id<P1,P2> anQualId = aBlock; // expected-error {{initializing 'id<P1,P2>' with an expression of incompatible type 'void (^)()'}}
id<P1,P2> anQualId = aBlock; // expected-error {{initializing 'id<P1,P2>' with an expression of incompatible type 'void (^)(void)'}}
NSArray* anArray = aBlock; // expected-error {{initializing 'NSArray *' with an expression of incompatible type 'void (^)()'}}
NSArray* anArray = aBlock; // expected-error {{initializing 'NSArray *' with an expression of incompatible type 'void (^)(void)'}}
aBlock = anId; // OK
id<P1,P2> anQualId1;
aBlock = anQualId1; // expected-error {{assigning to 'void (^)()' from incompatible type 'id<P1,P2>'}}
aBlock = anQualId1; // expected-error {{assigning to 'void (^)(void)' from incompatible type 'id<P1,P2>'}}
NSArray* anArray1;
aBlock = anArray1; // expected-error {{assigning to 'void (^)()' from incompatible type 'NSArray *'}}
aBlock = anArray1; // expected-error {{assigning to 'void (^)(void)' from incompatible type 'NSArray *'}}
}
voidTest2() {
void (^aBlock)();
voidTest2(void) {
void (^aBlock)(void);
id<NSObject> anQualId1 = aBlock; // Ok
id<NSObject, NSCopying> anQualId2 = aBlock; // Ok
id<NSObject, NSCopying, NSObject, NSCopying> anQualId3 = aBlock; // Ok
id <P1> anQualId4 = aBlock; // expected-error {{initializing 'id<P1>' with an expression of incompatible type 'void (^)()'}}
id<NSObject, P1, NSCopying> anQualId5 = aBlock; // expected-error {{initializing 'id<NSObject,P1,NSCopying>' with an expression of incompatible type 'void (^)()'}}
id <P1> anQualId4 = aBlock; // expected-error {{initializing 'id<P1>' with an expression of incompatible type 'void (^)(void)'}}
id<NSObject, P1, NSCopying> anQualId5 = aBlock; // expected-error {{initializing 'id<NSObject,P1,NSCopying>' with an expression of incompatible type 'void (^)(void)'}}
id<NSCopying> anQualId6 = aBlock; // Ok
}
voidTest3() {
void (^aBlock)();
voidTest3(void) {
void (^aBlock)(void);
NSObject *NSO = aBlock; // Ok
NSObject<NSObject> *NSO1 = aBlock; // Ok
NSObject<NSObject, NSCopying> *NSO2 = aBlock; // Ok
NSObject<NSObject, NSCopying, NSObject, NSCopying> *NSO3 = aBlock; // Ok
NSObject <P1> *NSO4 = aBlock; // expected-error {{initializing 'NSObject<P1> *' with an expression of incompatible type 'void (^)()'}}
NSObject<NSObject, P1, NSCopying> *NSO5 = aBlock; // expected-error {{initializing 'NSObject<NSObject,P1,NSCopying> *' with an expression of incompatible type 'void (^)()'}}
NSObject <P1> *NSO4 = aBlock; // expected-error {{initializing 'NSObject<P1> *' with an expression of incompatible type 'void (^)(void)'}}
NSObject<NSObject, P1, NSCopying> *NSO5 = aBlock; // expected-error {{initializing 'NSObject<NSObject,P1,NSCopying> *' with an expression of incompatible type 'void (^)(void)'}}
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
voidf0(int (^constbl)()); // expected-error{{declaring function parameter of type 'int (__generic ^const __private)(void)' is not allowed}}
voidf0(int (^constbl)(void)); // expected-error{{declaring function parameter of type 'int (__generic ^const __private)(void)' is not allowed}}
// All blocks declarations must be const qualified and initialized.
voidf1() {
int (^bl1)(void) = ^() {
voidf1(void) {
int (^bl1)(void) = ^(void) {
return1;
};
int (^constbl2)(void) = ^() {
int (^constbl2)(void) = ^(void) {
return1;
};
f0(bl1);
f0(bl2);
bl1=bl2; // expected-error{{invalid operands to binary expression ('int (__generic ^const __private)(void)' and 'int (__generic ^const __private)(void)')}}
int (^constbl3)(); // expected-error{{invalid block variable declaration - must be initialized}}
int (^constbl3)(void); // expected-error{{invalid block variable declaration - must be initialized}}
}
// A block with extern storage class is not allowed.
externint (^bl)(void) = ^() { // expected-error{{invalid block variable declaration - using 'extern' storage class is disallowed}}
externint (^bl)(void) = ^(void) { // expected-error{{invalid block variable declaration - using 'extern' storage class is disallowed}}
return1;
};
voidf2() {
externint (^bl)(void) = ^() { // expected-error{{invalid block variable declaration - using 'extern' storage class is disallowed}}
externint (^bl)(void) = ^(void) { // expected-error{{invalid block variable declaration - using 'extern' storage class is disallowed}}
return1;
};
}
Expand All
@@ -32,9 +32,9 @@ bl_t f3a(int); // expected-error{{declaring function return value of type 'b
bl_tf3b(bl_tbl);
// expected-error@-1{{declaring function return value of type 'bl_t' (aka 'int (__generic ^const)(void)') is not allowed}}
// expected-error@-2{{declaring function parameter of type '__private bl_t' (aka 'int (__generic ^const __private)(void)') is not allowed}}
voidf3c() {
voidf3c(void) {
// Block with a block argument.
int (^constbl2)(bl_tblock_arg) = ^() { // expected-error{{declaring function parameter of type '__private bl_t' (aka 'int (__generic ^const __private)(void)') is not allowed}}
int (^constbl2)(bl_tblock_arg) = ^(void) { // expected-error{{declaring function parameter of type '__private bl_t' (aka 'int (__generic ^const __private)(void)') is not allowed}}
returnblock_arg(); // expected-error{{implicit declaration of function 'block_arg' is invalid in OpenCL}}
};
}
Expand DownExpand Up
@@ -76,7 +76,7 @@ void f6(bl2_t *bl_ptr) { // expected-error{{pointer to type 'bl2_t' (aka 'int (_
&bl; // expected-error {{invalid argument type '__private bl2_t' (aka 'int (__generic ^const __private)(__private int)') to unary expression}}
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters