r224881 - Objective-C: Tweak unavailability warning.

Nico Weber nicolasweber at gmx.de
Fri Dec 26 23:09:37 PST 2014


Author: nico
Date: Sat Dec 27 01:09:37 2014
New Revision: 224881

URL: http://llvm.org/viewvc/llvm-project?rev=224881&view=rev
Log:
Objective-C: Tweak unavailability warning.

Don't warn when a selector has an unavailable and an available variant,
and the first also has an implementation.


Modified:
    cfe/trunk/lib/Sema/SemaDeclObjC.cpp
    cfe/trunk/test/SemaObjC/attr-deprecated.m

Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=224881&r1=224880&r2=224881&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Sat Dec 27 01:09:37 2014
@@ -2249,7 +2249,7 @@ void Sema::addMethodToGlobalList(ObjCMet
     // Propagate the 'defined' bit.
     if (Method->isDefined())
       PrevObjCMethod->setDefined(true);
-    else if (!PrevObjCMethod->isDefined()) {
+    else {
       // Objective-C doesn't allow an @interface for a class after its
       // @implementation. So if Method is not defined and there already is
       // an entry for this type signature, Method has to be for a different

Modified: cfe/trunk/test/SemaObjC/attr-deprecated.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/attr-deprecated.m?rev=224881&r1=224880&r2=224881&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/attr-deprecated.m (original)
+++ cfe/trunk/test/SemaObjC/attr-deprecated.m Sat Dec 27 01:09:37 2014
@@ -263,11 +263,24 @@ const char * func() {
 @end
 
 @interface InterfaceWithSameMethodAsUndeclaredImpl
-- (void)partiallyUnavailableMethod __attribute__((unavailable));  // expected-note{{explicitly marked unavailable here}}
+- (void)partiallyUnavailableMethod __attribute__((unavailable));
 @end
 
 void f(id a) {
-  // FIXME: Warning on this looks incorrect, since `a` could be an
-  // UndeclaredImpl object, where this method isn't inavailable.
-  [a partiallyUnavailableMethod]; // expected-error{{is unavailable}}
+  [a partiallyUnavailableMethod]; // no warning, `a` could be an UndeclaredImpl.
+}
+
+ at interface InterfaceWithImplementation
+- (void)anotherPartiallyUnavailableMethod;
+ at end
+ at implementation InterfaceWithImplementation
+- (void)anotherPartiallyUnavailableMethod {}
+ at end
+
+ at interface InterfaceWithSameMethodAsInterfaceWithImplementation
+- (void)anotherPartiallyUnavailableMethod __attribute__((unavailable));
+ at end
+
+void g(id a) {
+  [a anotherPartiallyUnavailableMethod]; // no warning, `a` could be an InterfaceWithImplementation.
 }





More information about the cfe-commits mailing list