]> granicus.if.org Git - clang/commitdiff
Warn if class object does not implement qualified
authorFariborz Jahanian <fjahanian@apple.com>
Mon, 9 Aug 2010 18:21:43 +0000 (18:21 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Mon, 9 Aug 2010 18:21:43 +0000 (18:21 +0000)
id's protocols. Fixes radar 8154220.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110583 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/ASTContext.cpp
test/SemaObjC/comptypes-5.m

index 2c16c07348367a20b54db94a75a321cddf314067..7d159269c1be8c8c6046dd1499b7d07f9605c737 100644 (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;
           }
index aaf64462b186717e827cf3bac0cf5cd7ee3ba232..f652f0e1a1f344bd1df0a0260927ec5503d1b579 100644 (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 */