]> granicus.if.org Git - clang/commitdiff
[Objective-C Sema] Patch to not issue unavailbility/deprecated
authorFariborz Jahanian <fjahanian@apple.com>
Tue, 7 Apr 2015 16:56:27 +0000 (16:56 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Tue, 7 Apr 2015 16:56:27 +0000 (16:56 +0000)
warning when multiple method declarations are found in global pool
with differing types and some are available.
rdar://20408445

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@234328 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDeclObjC.cpp
test/SemaObjC/multiple-property-deprecated-decl.m [new file with mode: 0644]

index 4865b08ddfd5e6ad734d27be1b7ac343f35f35dd..a12f2b1b3b1730a3df03df502885821343e81213 100644 (file)
@@ -2240,8 +2240,14 @@ void Sema::addMethodToGlobalList(ObjCMethodList *List,
     if (getLangOpts().Modules && !getLangOpts().CurrentModule.empty())
       continue;
 
-    if (!MatchTwoMethodDeclarations(Method, List->getMethod()))
+    if (!MatchTwoMethodDeclarations(Method, List->getMethod())) {
+      // Even if two method types do not match, we would like to say
+      // there is more than one declaration so unavailability/deprecated
+      // warning is not too noisy.
+      if (!Method->isDefined())
+        List->setHasMoreThanOneDecl(true);
       continue;
+    }
 
     ObjCMethodDecl *PrevObjCMethod = List->getMethod();
 
diff --git a/test/SemaObjC/multiple-property-deprecated-decl.m b/test/SemaObjC/multiple-property-deprecated-decl.m
new file mode 100644 (file)
index 0000000..d7dbd45
--- /dev/null
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1  -fsyntax-only -triple x86_64-apple-macosx10.11 -verify -Wno-objc-root-class %s
+// RUN: %clang_cc1 -x objective-c++ -fsyntax-only -triple x86_64-apple-macosx10.11 -verify -Wno-objc-root-class %s
+// expected-no-diagnostics
+// rdar://20408445
+@protocol NSFileManagerDelegate @end
+
+@interface NSFileManager 
+@property (assign) id <NSFileManagerDelegate> delegate;
+@end
+
+@interface NSFontManager
+@property (assign) id delegate __attribute__((availability(macosx,introduced=10.0 ,deprecated=10.11,message="" "NSFontManager doesn't have any delegate method. This property should not be used.")));
+
+@end
+
+id Test20408445(id p) {
+        return [p delegate];
+}