diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2013-04-27 00:10:12 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2013-04-27 00:10:12 +0000 |
commit | ab3d509bc45218c278454962ff644bb13d18ce1a (patch) | |
tree | 185294f2ad408fe3964c1401dc32604c1f771e6a | |
parent | 91efca0fa2ef5e63b48692e3439f5c6e6bde350c (diff) |
Fix an assertion hit in Sema::CheckObjCMethodOverrides.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@180651 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Sema/SemaDeclObjC.cpp | 10 | ||||
-rw-r--r-- | test/SemaObjC/protocol-lookup-2.m | 23 |
2 files changed, 29 insertions, 4 deletions
diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp index 271c7fcf36..41f96833df 100644 --- a/lib/Sema/SemaDeclObjC.cpp +++ b/lib/Sema/SemaDeclObjC.cpp @@ -2077,9 +2077,10 @@ bool Sema::MatchTwoMethodDeclarations(const ObjCMethodDecl *left, void Sema::addMethodToGlobalList(ObjCMethodList *List, ObjCMethodDecl *Method) { // Record at the head of the list whether there were 0, 1, or >= 2 methods // inside categories. - if (isa<ObjCCategoryDecl>(Method->getDeclContext())) - if (List->getBits() < 2) - List->setBits(List->getBits()+1); + if (ObjCCategoryDecl * + CD = dyn_cast<ObjCCategoryDecl>(Method->getDeclContext())) + if (!CD->IsClassExtension() && List->getBits() < 2) + List->setBits(List->getBits()+1); // If the list is empty, make it a singleton list. if (List->Method == 0) { @@ -2828,7 +2829,8 @@ void Sema::CheckObjCMethodOverrides(ObjCMethodDecl *ObjCMethod, for (OverrideSearch::iterator OI= overrides.begin(), OE= overrides.end(); OI!=OE; ++OI) { ObjCMethodDecl *SuperOverridden = *OI; - if (CurrentClass != SuperOverridden->getClassInterface()) { + if (isa<ObjCProtocolDecl>(SuperOverridden->getDeclContext()) || + CurrentClass != SuperOverridden->getClassInterface()) { hasOverriddenMethodsInBaseOrProtocol = true; overridden->setOverriding(true); break; diff --git a/test/SemaObjC/protocol-lookup-2.m b/test/SemaObjC/protocol-lookup-2.m index 9e8ed8a627..90f6db0c84 100644 --- a/test/SemaObjC/protocol-lookup-2.m +++ b/test/SemaObjC/protocol-lookup-2.m @@ -32,3 +32,26 @@ } @end + + +@protocol ProtC +-document; +@end + +@interface I1 : NSObject +@end + +@interface I1(cat) +-document; +@end + +@interface I2 : NSObject +-document; +@end + +@interface I2() <ProtC> +@end + +@implementation I2 +- document { return 0; } +@end |