From edf6059f52156dd0436fa93f00e874e1dab3231c Mon Sep 17 00:00:00 2001 From: Argyrios Kyrtzidis Date: Tue, 13 Oct 2015 23:27:34 +0000 Subject: [PATCH] [Sema/objc] When checking for unimplemented methods treat methods from class extensions as continuation of the class interface. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@250250 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaDeclObjC.cpp | 6 ++---- test/SemaObjC/class-extension-dup-methods.m | 12 ++++++++++++ test/SemaObjC/property-in-class-extension.m | 7 +++---- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp index 0ce463be6a..8217ba811e 100644 --- a/lib/Sema/SemaDeclObjC.cpp +++ b/lib/Sema/SemaDeclObjC.cpp @@ -2773,7 +2773,8 @@ void Sema::MatchAllMethodDeclarations(const SelectorSet &InsMap, if (!WarnCategoryMethodImpl) { for (auto *Cat : I->visible_categories()) MatchAllMethodDeclarations(InsMap, ClsMap, InsMapSeen, ClsMapSeen, - IMPDecl, Cat, IncompleteImpl, false, + IMPDecl, Cat, IncompleteImpl, + ImmediateClass && Cat->IsClassExtension(), WarnCategoryMethodImpl); } else { // Also methods in class extensions need be looked at next. @@ -2890,9 +2891,6 @@ void Sema::ImplMethodsVsClassMethods(Scope *S, ObjCImplDecl* IMPDecl, for (auto *PI : I->all_referenced_protocols()) CheckProtocolMethodDefs(*this, IMPDecl->getLocation(), PI, IncompleteImpl, InsMap, ClsMap, I, ExplicitImplProtocols); - // Check class extensions (unnamed categories) - for (auto *Ext : I->visible_extensions()) - ImplMethodsVsClassMethods(S, IMPDecl, Ext, IncompleteImpl); } else if (ObjCCategoryDecl *C = dyn_cast(CDecl)) { // For extended class, unimplemented methods in its protocols will // be reported in the primary class. diff --git a/test/SemaObjC/class-extension-dup-methods.m b/test/SemaObjC/class-extension-dup-methods.m index 5f463aed16..446d2be037 100644 --- a/test/SemaObjC/class-extension-dup-methods.m +++ b/test/SemaObjC/class-extension-dup-methods.m @@ -26,3 +26,15 @@ __attribute__((objc_root_class)) @interface AppDelegate - (void)someMethodWithArgument:(float)argument; // OK. No warning to be issued here. + (void)someMethodWithArgument:(float)argument : (float)argument2; // expected-error {{duplicate declaration of method 'someMethodWithArgument::'}} @end + +__attribute__((objc_root_class)) +@interface Test +-(void)meth; // expected-note {{declared here}} +@end + +@interface Test() +-(void)meth; +@end + +@implementation Test // expected-warning {{method definition for 'meth' not found}} +@end diff --git a/test/SemaObjC/property-in-class-extension.m b/test/SemaObjC/property-in-class-extension.m index 022a487ec6..a780a35219 100644 --- a/test/SemaObjC/property-in-class-extension.m +++ b/test/SemaObjC/property-in-class-extension.m @@ -37,12 +37,11 @@ void FUNC () { @interface rdar8747333 () - (NSObject *)bam; -- (NSObject *)warn; // expected-note {{method 'warn' declared here}} -- (void)setWarn : (NSObject *)val; // expected-note {{method 'setWarn:' declared here}} +- (NSObject *)warn; +- (void)setWarn : (NSObject *)val; @end -@implementation rdar8747333 // expected-warning {{method definition for 'warn' not found}} \ - // expected-warning {{method definition for 'setWarn:' not found}} +@implementation rdar8747333 @synthesize bar = _bar; @synthesize baz = _baz; @synthesize bam = _bam; -- 2.40.0