For @optional unimplemented methods do not issue the warning.

llvm-svn: 44872
This commit is contained in:
Fariborz Jahanian 2007-12-11 19:10:26 +00:00
parent 5143d898c8
commit 3b5dca2533
2 changed files with 25 additions and 2 deletions

View File

@ -1532,7 +1532,8 @@ void Sema::CheckProtocolMethodDefs(ObjcProtocolDecl *PDecl,
// check unimplemented instance methods.
ObjcMethodDecl** methods = PDecl->getInstanceMethods();
for (int j = 0; j < PDecl->getNumInstanceMethods(); j++) {
if (!InsMap.count(methods[j]->getSelector())) {
if (!InsMap.count(methods[j]->getSelector()) &&
methods[j]->getImplementationControl() != ObjcMethodDecl::Optional) {
Diag(methods[j]->getLocation(), diag::warn_undef_method_impl,
methods[j]->getSelector().getName());
IncompleteImpl = true;
@ -1541,7 +1542,8 @@ void Sema::CheckProtocolMethodDefs(ObjcProtocolDecl *PDecl,
// check unimplemented class methods
methods = PDecl->getClassMethods();
for (int j = 0; j < PDecl->getNumClassMethods(); j++)
if (!ClsMap.count(methods[j]->getSelector())) {
if (!ClsMap.count(methods[j]->getSelector()) &&
methods[j]->getImplementationControl() != ObjcMethodDecl::Optional) {
Diag(methods[j]->getLocation(), diag::warn_undef_method_impl,
methods[j]->getSelector().getName());
IncompleteImpl = true;

View File

@ -0,0 +1,21 @@
// RUN: clang -verify %s
@protocol MyProto1
@optional
- (void) FOO;
@optional
- (void) FOO;
@optional
- (void) REQ;
@optional
@end
@interface MyProto2 <MyProto1>
- (void) FOO2;
- (void) FOO3;
@end
@implementation MyProto2
- (void) FOO2{}
- (void) FOO3{}
@end