From b072b7125b3e2c03da66179704bff9c16808178a Mon Sep 17 00:00:00 2001 From: Fariborz Jahanian Date: Fri, 3 Apr 2009 21:51:32 +0000 Subject: [PATCH] Real corener case of a method declared in a protocol used in a class which declares a property of the same name. This should not result in an unimplemented method warning. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68409 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaDeclObjC.cpp | 11 +++++++++-- test/SemaObjC/no-warn-synth-protocol-meth.m | 17 +++++++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 test/SemaObjC/no-warn-synth-protocol-meth.m diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp index fb042651f6..299f101bdb 100644 --- a/lib/Sema/SemaDeclObjC.cpp +++ b/lib/Sema/SemaDeclObjC.cpp @@ -866,8 +866,15 @@ void Sema::CheckProtocolMethodDefs(SourceLocation ImpLoc, ObjCMethodDecl *method = *I; if (method->getImplementationControl() != ObjCMethodDecl::Optional && !method->isSynthesized() && !InsMap.count(method->getSelector()) && - (!Super || !Super->lookupInstanceMethod(method->getSelector()))) - WarnUndefinedMethod(ImpLoc, method, IncompleteImpl); + (!Super || !Super->lookupInstanceMethod(method->getSelector()))) { + // Ugly, but necessary. Method declared in protcol might have + // have been synthesized due to a property declared in the class which + // uses the protocol. + ObjCMethodDecl *MethodInClass = + IDecl->lookupInstanceMethod(method->getSelector()); + if (!MethodInClass || !MethodInClass->isSynthesized()) + WarnUndefinedMethod(ImpLoc, method, IncompleteImpl); + } } // check unimplemented class methods for (ObjCProtocolDecl::classmeth_iterator I = PDecl->classmeth_begin(), diff --git a/test/SemaObjC/no-warn-synth-protocol-meth.m b/test/SemaObjC/no-warn-synth-protocol-meth.m new file mode 100644 index 0000000000..860a0ca2be --- /dev/null +++ b/test/SemaObjC/no-warn-synth-protocol-meth.m @@ -0,0 +1,17 @@ +// RUN: clang-cc -fsyntax-only -verify %s + +@protocol CYCdef +- (int)name; +@end + +@interface JSCdef { + int name; +} + +@property (assign) int name; +@end + +@implementation JSCdef +@synthesize name; +@end + -- 2.40.0