an Objective-C object type other than 'id'.
// rdar://
16739120
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@209906
91177308-0d34-0410-b5e6-
96231b3b80d8
return IncompatiblePointer;
}
- // T^ -> A*
- if (RHSType->isBlockPointerType()) {
+ // T^ -> id; not T^ ->A* and not T^ -> id<P>
+ if (RHSType->isBlockPointerType() && LHSType->isObjCIdType()) {
maybeExtendBlockObject(*this, RHS);
Kind = CK_BlockPointerToObjCPointerCast;
return Compatible;
return NSOrderedSame;
}];
}
+
+// rdar://16739120
+@protocol P1 @end
+@protocol P2 @end
+
+void Test() {
+void (^aBlock)();
+id anId = aBlock; // OK
+
+id<P1,P2> anQualId = aBlock; // expected-error {{initializing 'id<P1,P2>' with an expression of incompatible type 'void (^)()'}}
+
+NSArray* anArray = aBlock; // expected-error {{initializing 'NSArray *' with an expression of incompatible type 'void (^)()'}}
+
+aBlock = anId; // OK
+
+id<P1,P2> anQualId1;
+aBlock = anQualId1; // expected-error {{assigning to 'void (^)()' from incompatible type 'id<P1,P2>'}}
+
+NSArray* anArray1;
+aBlock = anArray1; // expected-error {{assigning to 'void (^)()' from incompatible type 'NSArray *'}}
+}
+