diff options
| author | Chris Lattner <sabre@nondot.org> | 2008-04-07 06:06:56 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2008-04-07 06:06:56 +0000 |
| commit | c9062d01d7978d57a310283153f35ca3c8eaffbb (patch) | |
| tree | 1287929611d7d7ef819cfebc4b74e3add4adecde /clang | |
| parent | 7bbd3d75efd9193762e14ea7bde87c91668e2eae (diff) | |
| download | bcm5719-llvm-c9062d01d7978d57a310283153f35ca3c8eaffbb.tar.gz bcm5719-llvm-c9062d01d7978d57a310283153f35ca3c8eaffbb.zip | |
MyOtherClass<MyProtocol>* is compatible with MyClass*
if MyClass is a superclass of MyOtherClass, there is no need for
an exact interface match.
llvm-svn: 49320
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/lib/AST/ASTContext.cpp | 3 | ||||
| -rw-r--r-- | clang/test/Sema/objc-comptypes-5.m | 6 |
2 files changed, 7 insertions, 2 deletions
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index 355308a40ca..c071e5ebd62 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -1441,7 +1441,8 @@ static bool areCompatObjCInterfaces(const ObjCInterfaceType *LHS, const ObjCInterfaceType *RHS) { // II is compatible with II<P> if the base is the same. Otherwise, no two // qualified interface types are the same. - if (LHS->getDecl() != RHS->getDecl()) return false; + if (!LHS->getDecl()->isSuperClassOf(RHS->getDecl())) + return false; // If the base decls match and one is a qualified interface and one isn't, // then they are compatible. diff --git a/clang/test/Sema/objc-comptypes-5.m b/clang/test/Sema/objc-comptypes-5.m index e594a6e35db..7101e960438 100644 --- a/clang/test/Sema/objc-comptypes-5.m +++ b/clang/test/Sema/objc-comptypes-5.m @@ -1,4 +1,4 @@ -// RUN: clang -fsyntax-only -verify %s +// RUN: clang -fsyntax-only -pedantic -verify %s #define nil (void *)0; @@ -23,6 +23,7 @@ int main() id <MyProtocol> obj_id_p = nil; MyClass *obj_c_cat_p = nil; MyOtherClass *obj_c_super_p = nil; + MyOtherClass<MyProtocol> *obj_c_super_p_q = nil; obj_c_cat_p = obj_id_p; // expected-error {{incompatible type assigning 'id<MyProtocol>', expected 'MyClass *'}} obj_c_super_p = obj_id_p; // expected-error {{incompatible type assigning 'id<MyProtocol>', expected 'MyOtherClass *'}} @@ -34,5 +35,8 @@ int main() if (obj_id_p == obj_c_cat_p) foo(); /* Ok */ if (obj_id_p == obj_c_super_p) foo(); /* Ok */ + obj_c_cat_p = obj_c_super_p; // ok. + obj_c_cat_p = obj_c_super_p_q; // ok. + return 0; } |

