summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2009-04-03 21:51:32 +0000
committerFariborz Jahanian <fjahanian@apple.com>2009-04-03 21:51:32 +0000
commit2705859981d12d1f66e9d480b682690ce47a2b72 (patch)
tree273023e40bd8e29f5b99a48cece7105986120440 /clang
parent6c7917a844d49178eac40fd78f569bb63e20d622 (diff)
downloadbcm5719-llvm-2705859981d12d1f66e9d480b682690ce47a2b72.tar.gz
bcm5719-llvm-2705859981d12d1f66e9d480b682690ce47a2b72.zip
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. llvm-svn: 68409
Diffstat (limited to 'clang')
-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