From: Nico Weber Date: Sat, 27 Dec 2014 07:09:37 +0000 (+0000) Subject: Objective-C: Tweak unavailability warning. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8fe261c229dbd8516e13c6e5a3ad5fc554ad0d26;p=clang 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@224881 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp index 90835be722..7e3da941b3 100644 --- a/lib/Sema/SemaDeclObjC.cpp +++ b/lib/Sema/SemaDeclObjC.cpp @@ -2249,7 +2249,7 @@ void Sema::addMethodToGlobalList(ObjCMethodList *List, // 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 diff --git a/test/SemaObjC/attr-deprecated.m b/test/SemaObjC/attr-deprecated.m index 416e464101..13ba68db58 100644 --- a/test/SemaObjC/attr-deprecated.m +++ b/test/SemaObjC/attr-deprecated.m @@ -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. +} + +@interface InterfaceWithImplementation +- (void)anotherPartiallyUnavailableMethod; +@end +@implementation InterfaceWithImplementation +- (void)anotherPartiallyUnavailableMethod {} +@end + +@interface InterfaceWithSameMethodAsInterfaceWithImplementation +- (void)anotherPartiallyUnavailableMethod __attribute__((unavailable)); +@end + +void g(id a) { + [a anotherPartiallyUnavailableMethod]; // no warning, `a` could be an InterfaceWithImplementation. }