diff --git a/clang/lib/Sema/SemaExprObjC.cpp b/clang/lib/Sema/SemaExprObjC.cpp index ae9942b1c3eb..0730cf6e7bfc 100644 --- a/clang/lib/Sema/SemaExprObjC.cpp +++ b/clang/lib/Sema/SemaExprObjC.cpp @@ -2448,10 +2448,14 @@ ExprResult Sema::BuildInstanceMessage(Expr *Receiver, Method = LookupFactoryMethodInGlobalPool(Sel, SourceRange(LBracLoc,RBracLoc), receiverIsId); - if (Method) + if (Method) { if (ObjCMethodDecl *BestMethod = SelectBestMethod(Sel, ArgsIn, Method->isInstanceMethod())) Method = BestMethod; + SmallVector Methods; + if (!CollectMultipleMethodsInGlobalPool(Sel, Methods, Method->isInstanceMethod())) + DiagnoseUseOfDecl(Method, SelLoc); + } } else if (ReceiverType->isObjCClassType() || ReceiverType->isObjCQualifiedClassType()) { // Handle messages to Class. diff --git a/clang/test/ARCMT/checking.m b/clang/test/ARCMT/checking.m index d8ccf1675230..76c444307678 100644 --- a/clang/test/ARCMT/checking.m +++ b/clang/test/ARCMT/checking.m @@ -14,9 +14,9 @@ typedef int BOOL; typedef unsigned NSUInteger; @protocol NSObject -- (id)retain NS_AUTOMATED_REFCOUNT_UNAVAILABLE; +- (id)retain NS_AUTOMATED_REFCOUNT_UNAVAILABLE; // expected-note {{'retain' has been explicitly marked unavailable here}} - (NSUInteger)retainCount NS_AUTOMATED_REFCOUNT_UNAVAILABLE; -- (oneway void)release NS_AUTOMATED_REFCOUNT_UNAVAILABLE; +- (oneway void)release NS_AUTOMATED_REFCOUNT_UNAVAILABLE; // expected-note 4 {{'release' has been explicitly marked unavailable here}} - (id)autorelease NS_AUTOMATED_REFCOUNT_UNAVAILABLE; @end @@ -74,16 +74,20 @@ id global_foo; void test1(A *a, BOOL b, struct UnsafeS *unsafeS) { [[a delegate] release]; // expected-error {{it is not safe to remove 'retain' message on the result of a 'delegate' message; the object that was passed to 'setDelegate:' may not be properly retained}} \ + // expected-error {{'release' is unavailable: not available in automatic reference counting mode}} \ // expected-error {{ARC forbids explicit message send}} [a.delegate release]; // expected-error {{it is not safe to remove 'retain' message on the result of a 'delegate' message; the object that was passed to 'setDelegate:' may not be properly retained}} \ + // expected-error {{'release' is unavailable: not available in automatic reference counting mode}} \ // expected-error {{ARC forbids explicit message send}} [unsafeS->unsafeObj retain]; // expected-error {{it is not safe to remove 'retain' message on an __unsafe_unretained type}} \ // expected-error {{ARC forbids explicit message send}} \ // expected-error {{'retain' is unavailable}} id foo = [unsafeS->unsafeObj retain]; // no warning. [global_foo retain]; // expected-error {{it is not safe to remove 'retain' message on a global variable}} \ + // expected-error {{'retain' is unavailable: not available in automatic reference counting mode}} \ // expected-error {{ARC forbids explicit message send}} [global_foo release]; // expected-error {{it is not safe to remove 'release' message on a global variable}} \ + // expected-error {{'release' is unavailable: not available in automatic reference counting mode}} \ // expected-error {{ARC forbids explicit message send}} [a dealloc]; [a retain]; @@ -304,7 +308,8 @@ void rdar9491791(int p) { // rdar://9504750 void rdar9504750(id p) { - RELEASE_MACRO(p); // expected-error {{ARC forbids explicit message send of 'release'}} + RELEASE_MACRO(p); // expected-error {{ARC forbids explicit message send of 'release'}} \ + // expected-error {{'release' is unavailable: not available in automatic reference counting mode}} } // rdar://8939557 diff --git a/clang/test/SemaObjC/attr-deprecated.m b/clang/test/SemaObjC/attr-deprecated.m index 4eb56ee7d746..20d8c1066eba 100644 --- a/clang/test/SemaObjC/attr-deprecated.m +++ b/clang/test/SemaObjC/attr-deprecated.m @@ -5,7 +5,7 @@ int X __attribute__((deprecated)); // expected-note 2 {{'X' has been explicitly marked deprecated here}} } + (void)F __attribute__((deprecated)); // expected-note 2 {{'F' has been explicitly marked deprecated here}} -- (void)f __attribute__((deprecated)); // expected-note 4 {{'f' has been explicitly marked deprecated here}} +- (void)f __attribute__((deprecated)); // expected-note 5 {{'f' has been explicitly marked deprecated here}} @end @implementation A @@ -54,7 +54,7 @@ void t1(A *a) void t2(id a) { - [a f]; + [a f]; // expected-warning {{'f' is deprecated}} } void t3(A

* a) @@ -228,3 +228,13 @@ expected-note {{property declared here}} @end +// rdar://18848183 +@interface NSString +- (const char *)cString __attribute__((availability(macosx,introduced=10.0 ,deprecated=10.4,message="" ))); // expected-note {{'cString' has been explicitly marked deprecated here}} +@end + +id PID = 0; +const char * func() { + return [PID cString]; // expected-warning {{'cString' is deprecated: first deprecated in OS X 10.4}} +} +