[cfe-commits] r68409 - in /cfe/trunk: lib/Sema/SemaDeclObjC.cpp test/SemaObjC/no-warn-synth-protocol-meth.m
Fariborz Jahanian
fjahanian at apple.com
Fri Apr 3 14:51:32 PDT 2009
Author: fjahanian
Date: Fri Apr 3 16:51:32 2009
New Revision: 68409
URL: http://llvm.org/viewvc/llvm-project?rev=68409&view=rev
Log:
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.
Added:
cfe/trunk/test/SemaObjC/no-warn-synth-protocol-meth.m
Modified:
cfe/trunk/lib/Sema/SemaDeclObjC.cpp
Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=68409&r1=68408&r2=68409&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Fri Apr 3 16:51:32 2009
@@ -866,8 +866,15 @@
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(),
Added: cfe/trunk/test/SemaObjC/no-warn-synth-protocol-meth.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/no-warn-synth-protocol-meth.m?rev=68409&view=auto
==============================================================================
--- cfe/trunk/test/SemaObjC/no-warn-synth-protocol-meth.m (added)
+++ cfe/trunk/test/SemaObjC/no-warn-synth-protocol-meth.m Fri Apr 3 16:51:32 2009
@@ -0,0 +1,17 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+
+ at protocol CYCdef
+- (int)name;
+ at end
+
+ at interface JSCdef <CYCdef> {
+ int name;
+}
+
+ at property (assign) int name;
+ at end
+
+ at implementation JSCdef
+ at synthesize name;
+ at end
+
More information about the cfe-commits
mailing list