diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2010-08-09 18:21:43 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2010-08-09 18:21:43 +0000 |
commit | d1909bbc8aa8b468527250766c8f4e67379da2d6 (patch) | |
tree | 604312fa5b9b8578ff35bd566717ade2615c25d2 | |
parent | b29bde7ca5dd2c09214f1ab1084c33a3c5452486 (diff) |
Warn if class object does not implement qualified
id's protocols. Fixes radar 8154220.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110583 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/AST/ASTContext.cpp | 8 | ||||
-rw-r--r-- | test/SemaObjC/comptypes-5.m | 4 |
2 files changed, 6 insertions, 6 deletions
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index 2c16c07348..7d159269c1 100644 --- a/lib/AST/ASTContext.cpp +++ b/lib/AST/ASTContext.cpp @@ -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; } diff --git a/test/SemaObjC/comptypes-5.m b/test/SemaObjC/comptypes-5.m index aaf64462b1..f652f0e1a1 100644 --- a/test/SemaObjC/comptypes-5.m +++ b/test/SemaObjC/comptypes-5.m @@ -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 */ |