]> granicus.if.org Git - clang/commitdiff
For @optional unimplemented methods do not issue the warning.
authorFariborz Jahanian <fjahanian@apple.com>
Tue, 11 Dec 2007 19:10:26 +0000 (19:10 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Tue, 11 Dec 2007 19:10:26 +0000 (19:10 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@44872 91177308-0d34-0410-b5e6-96231b3b80d8

Sema/SemaDecl.cpp
test/Sema/enhanced-proto-2.m [new file with mode: 0644]

index 0e3e7283b99f191d5cb3a1855f96a34f7675e3d8..8a67bbe1f43968aecc05b7c2ad2cc350fdc8dff0 100644 (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;
diff --git a/test/Sema/enhanced-proto-2.m b/test/Sema/enhanced-proto-2.m
new file mode 100644 (file)
index 0000000..82e23c4
--- /dev/null
@@ -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