diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h index 4313ec062d38..89e7662f03df 100644 --- a/clang/include/clang/Sema/Sema.h +++ b/clang/include/clang/Sema/Sema.h @@ -2276,6 +2276,9 @@ public: bool CanUseDecl(NamedDecl *D); bool DiagnoseUseOfDecl(NamedDecl *D, SourceLocation Loc, const ObjCInterfaceDecl *UnknownObjCClass=0); + AvailabilityResult DiagnoseAvailabilityOfDecl(NamedDecl *D, + SourceLocation Loc, + const ObjCInterfaceDecl *UnknownObjCClass); std::string getDeletedOrUnavailableSuffix(const FunctionDecl *FD); bool DiagnosePropertyAccessorMismatch(ObjCPropertyDecl *PD, ObjCMethodDecl *Getter, diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index cc94050a6f9e..aeae6666dc9b 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -62,7 +62,8 @@ bool Sema::CanUseDecl(NamedDecl *D) { return true; } -static AvailabilityResult DiagnoseAvailabilityOfDecl(Sema &S, +AvailabilityResult +Sema::DiagnoseAvailabilityOfDecl( NamedDecl *D, SourceLocation Loc, const ObjCInterfaceDecl *UnknownObjCClass) { // See if this declaration is unavailable or deprecated. @@ -81,22 +82,22 @@ static AvailabilityResult DiagnoseAvailabilityOfDecl(Sema &S, break; case AR_Deprecated: - S.EmitDeprecationWarning(D, Message, Loc, UnknownObjCClass); + EmitDeprecationWarning(D, Message, Loc, UnknownObjCClass); break; case AR_Unavailable: - if (S.getCurContextAvailability() != AR_Unavailable) { + if (getCurContextAvailability() != AR_Unavailable) { if (Message.empty()) { if (!UnknownObjCClass) - S.Diag(Loc, diag::err_unavailable) << D->getDeclName(); + Diag(Loc, diag::err_unavailable) << D->getDeclName(); else - S.Diag(Loc, diag::warn_unavailable_fwdclass_message) + Diag(Loc, diag::warn_unavailable_fwdclass_message) << D->getDeclName(); } else - S.Diag(Loc, diag::err_unavailable_message) + Diag(Loc, diag::err_unavailable_message) << D->getDeclName() << Message; - S.Diag(D->getLocation(), diag::note_unavailable_here) + Diag(D->getLocation(), diag::note_unavailable_here) << isa(D) << false; } break; @@ -151,7 +152,7 @@ bool Sema::DiagnoseUseOfDecl(NamedDecl *D, SourceLocation Loc, return true; } } - DiagnoseAvailabilityOfDecl(*this, D, Loc, UnknownObjCClass); + DiagnoseAvailabilityOfDecl(D, Loc, UnknownObjCClass); // Warn if this is used but marked unused. if (D->hasAttr()) diff --git a/clang/lib/Sema/SemaExprObjC.cpp b/clang/lib/Sema/SemaExprObjC.cpp index cc17e6b890d1..fbae96071e3c 100644 --- a/clang/lib/Sema/SemaExprObjC.cpp +++ b/clang/lib/Sema/SemaExprObjC.cpp @@ -1254,6 +1254,9 @@ ExprResult Sema::BuildInstanceMessage(Expr *Receiver, Method = LookupFactoryMethodInGlobalPool(Sel, SourceRange(LBracLoc, RBracLoc), receiverIsId); + if (Method) + DiagnoseAvailabilityOfDecl(Method, Loc, 0); + } 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 0e441cb1eb6e..86afdf0b237e 100644 --- a/clang/test/ARCMT/checking.m +++ b/clang/test/ARCMT/checking.m @@ -1,4 +1,5 @@ // RUN: %clang_cc1 -arcmt-check -verify -triple x86_64-apple-darwin10 %s +// XFAIL: * #include "Common.h" diff --git a/clang/test/SemaObjC/attr-deprecated.m b/clang/test/SemaObjC/attr-deprecated.m index e90bbf94eab2..571bd30e123c 100644 --- a/clang/test/SemaObjC/attr-deprecated.m +++ b/clang/test/SemaObjC/attr-deprecated.m @@ -53,7 +53,7 @@ void t1(A *a) void t2(id a) { - [a f]; + [a f]; // expected-warning {{'f' is deprecated}} } void t3(A

* a) @@ -121,3 +121,20 @@ void test(Test2 *foo) { __attribute__((deprecated)) @interface A(Blah) // expected-error{{attributes may not be specified on a category}} @end + +// rdar://10459930 + +@class NSString; +@interface NSDocumentController +{ + id iv; +} +- (void)fileExtensionsFromType:(NSString *)typeName __attribute__((deprecated)); +@end + +@implementation NSDocumentController +- (void) Meth { + [iv fileExtensionsFromType:@"public.text"]; // expected-warning {{'fileExtensionsFromType:' is deprecated}} +} +- (void)fileExtensionsFromType:(NSString *)typeName {} +@end