From 6bdeb14d5d347b17c9bde8ab39c9d69b16a56a13 Mon Sep 17 00:00:00 2001 From: Fariborz Jahanian Date: Wed, 7 Dec 2011 00:30:00 +0000 Subject: objc: issue deprecated/unavailable diagnostic when methods with these attributes are sent to receivers of 'id' type too. // rdar://10459930 llvm-svn: 145999 --- clang/lib/Sema/SemaExpr.cpp | 17 +++++++++-------- clang/lib/Sema/SemaExprObjC.cpp | 3 +++ 2 files changed, 12 insertions(+), 8 deletions(-) (limited to 'clang/lib') diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index cc94050a6f9..aeae6666dc9 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 cc17e6b890d..fbae96071e3 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. -- cgit v1.2.3