forked from OSchip/llvm-project
Objective-C. Diagnose assigning a block pointer type to
an Objective-C object type other than 'id'. // rdar://16739120 llvm-svn: 209906
This commit is contained in:
parent
0ae08a849d
commit
b3a7068700
|
@ -6435,8 +6435,8 @@ Sema::CheckAssignmentConstraints(QualType LHSType, ExprResult &RHS,
|
|||
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;
|
||||
|
|
|
@ -155,3 +155,25 @@ void f() {
|
|||
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 *'}}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue