summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/lib/Sema/SemaDeclObjC.cpp11
-rw-r--r--clang/test/SemaObjC/no-warn-synth-protocol-meth.m17
2 files changed, 26 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaDeclObjC.cpp b/clang/lib/Sema/SemaDeclObjC.cpp
index fb042651f6d..299f101bdbf 100644
--- a/clang/lib/Sema/SemaDeclObjC.cpp
+++ b/clang/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/clang/test/SemaObjC/no-warn-synth-protocol-meth.m b/clang/test/SemaObjC/no-warn-synth-protocol-meth.m
new file mode 100644
index 00000000000..860a0ca2bef
--- /dev/null
+++ b/clang/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 <CYCdef> {
+ int name;
+}
+
+@property (assign) int name;
+@end
+
+@implementation JSCdef
+@synthesize name;
+@end
+
OpenPOWER on IntegriCloud