diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2007-12-11 19:10:26 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2007-12-11 19:10:26 +0000 |
commit | 0105556097a3e381662137fc35e7da7766cbb7d8 (patch) | |
tree | c6235d34d85a62fea8a4ad3358f6f8327b0dc010 | |
parent | f366b4c84485b646c30d6891a249ad6f65abef7c (diff) |
For @optional unimplemented methods do not issue the warning.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@44872 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | Sema/SemaDecl.cpp | 6 | ||||
-rw-r--r-- | test/Sema/enhanced-proto-2.m | 21 |
2 files changed, 25 insertions, 2 deletions
diff --git a/Sema/SemaDecl.cpp b/Sema/SemaDecl.cpp index 0e3e7283b9..8a67bbe1f4 100644 --- a/Sema/SemaDecl.cpp +++ b/Sema/SemaDecl.cpp @@ -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; diff --git a/test/Sema/enhanced-proto-2.m b/test/Sema/enhanced-proto-2.m new file mode 100644 index 0000000000..82e23c4b63 --- /dev/null +++ b/test/Sema/enhanced-proto-2.m @@ -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 |