Warn if class object does not implement qualified

id's protocols. Fixes radar 8154220.

llvm-svn: 110583
This commit is contained in:
Fariborz Jahanian 2010-08-09 18:21:43 +00:00
parent c33940b3aa
commit ec43022b99
2 changed files with 6 additions and 6 deletions

View File

@ -4323,10 +4323,10 @@ bool ASTContext::ObjCQualifiedIdTypesAreCompatible(QualType lhs, QualType rhs,
if (ObjCInterfaceDecl *lhsID = lhsOPT->getInterfaceDecl()) {
for (ObjCObjectPointerType::qual_iterator I = rhsQID->qual_begin(),
E = rhsQID->qual_end(); I != E; ++I) {
// when comparing an id<P> on lhs with a static type on rhs,
// see if static class implements all of id's protocols, directly or
// through its super class and categories.
if (lhsID->ClassImplementsProtocol(*I, true)) {
// when comparing an id<P> on rhs with a static type on lhs,
// static class must implement all of id's protocols directly or
// indirectly through its super class.
if (lhsID->ClassImplementsProtocol(*I, false)) {
match = true;
break;
}

View File

@ -26,8 +26,8 @@ int main()
MyOtherClass<MyProtocol> *obj_c_super_p_q = nil;
MyClass<MyProtocol> *obj_c_cat_p_q = nil;
obj_c_cat_p = obj_id_p;
obj_c_super_p = obj_id_p;
obj_c_cat_p = obj_id_p; // expected-warning {{assigning to 'MyClass *' from incompatible type 'id<MyProtocol>'}}
obj_c_super_p = obj_id_p; // expected-warning {{assigning to 'MyOtherClass *' from incompatible type 'id<MyProtocol>'}}
obj_id_p = obj_c_cat_p; /* Ok */
obj_id_p = obj_c_super_p; /* Ok */