]> granicus.if.org Git - clang/commitdiff
"note" location of forward class used as receiver of
authorFariborz Jahanian <fjahanian@apple.com>
Sat, 23 Apr 2011 17:27:19 +0000 (17:27 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Sat, 23 Apr 2011 17:27:19 +0000 (17:27 +0000)
a 'deprecated' selector in the diagnostics for the
selector. // rdar://9309223

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130062 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Sema/Sema.h
lib/Sema/SemaDeclAttr.cpp
lib/Sema/SemaExpr.cpp
lib/Sema/SemaExprObjC.cpp
test/SemaObjC/special-dep-unavail-warning.m

index 21e5d945c9130b6c826c3c7a66befb75aaa27540..940d213e57374f84b176074dd36251dbc1c524b6 100644 (file)
@@ -1923,7 +1923,8 @@ public:
   }
 
   void EmitDeprecationWarning(NamedDecl *D, llvm::StringRef Message,
-                              SourceLocation Loc, bool UnknownObjCClass=false);
+                              SourceLocation Loc, 
+                              const ObjCInterfaceDecl *UnknownObjCClass=0);
 
   void HandleDelayedDeprecationCheck(sema::DelayedDiagnostic &DD, Decl *Ctx);
 
@@ -1931,7 +1932,7 @@ public:
   // Expression Parsing Callbacks: SemaExpr.cpp.
 
   bool DiagnoseUseOfDecl(NamedDecl *D, SourceLocation Loc, 
-                         bool UnknownObjCClass=false);
+                         const ObjCInterfaceDecl *UnknownObjCClass=0);
   std::string getDeletedOrUnavailableSuffix(const FunctionDecl *FD);
   bool DiagnosePropertyAccessorMismatch(ObjCPropertyDecl *PD,
                                         ObjCMethodDecl *Getter,
index 244f70a2dbe6f92f7daee1e9b12b990b650d913c..746c5dbb37440bf507b526a1f98ee7a77ee70a38 100644 (file)
@@ -3175,7 +3175,7 @@ void Sema::HandleDelayedDeprecationCheck(DelayedDiagnostic &DD,
 
 void Sema::EmitDeprecationWarning(NamedDecl *D, llvm::StringRef Message,
                                   SourceLocation Loc,
-                                  bool UnknownObjCClass) {
+                                  const ObjCInterfaceDecl *UnknownObjCClass) {
   // Delay if we're currently parsing a declaration.
   if (DelayedDiagnostics.shouldDelayDiagnostics()) {
     DelayedDiagnostics.add(DelayedDiagnostic::makeDeprecation(Loc, D, Message));
@@ -3191,7 +3191,9 @@ void Sema::EmitDeprecationWarning(NamedDecl *D, llvm::StringRef Message,
   else {
     if (!UnknownObjCClass)
       Diag(Loc, diag::warn_deprecated) << D->getDeclName();
-    else
+    else {
       Diag(Loc, diag::warn_deprecated_fwdclass_message) << D->getDeclName();
+      Diag(UnknownObjCClass->getLocation(), diag::note_forward_class);
+    }
   }
 }
index a773c3a8173083c044302eab06fa11c77188bdb1..da7619d0f466dd6a9de01efb5f1846da8ae740a4 100644 (file)
@@ -56,7 +56,7 @@ using namespace sema;
 /// referenced), false otherwise.
 ///
 bool Sema::DiagnoseUseOfDecl(NamedDecl *D, SourceLocation Loc,
-                             bool UnknownObjCClass) {
+                             const ObjCInterfaceDecl *UnknownObjCClass) {
   if (getLangOptions().CPlusPlus && isa<FunctionDecl>(D)) {
     // If there were any diagnostics suppressed by template argument deduction,
     // emit them now.
index 04f5e32bda703d2868ed763290ca5fabd9c801f3..2a262f09392211ef57000565943492c5e8d7868a 100644 (file)
@@ -1155,7 +1155,7 @@ ExprResult Sema::BuildInstanceMessage(Expr *Receiver,
           // Search protocol qualifiers.
           Method = LookupMethodInQualifiedType(Sel, OCIType, true);
         
-        bool forwardClass = false;
+        const ObjCInterfaceDecl *forwardClass = 0;
         if (!Method) {
           // If we have implementations in scope, check "private" methods.
           Method = LookupPrivateInstanceMethod(Sel, ClassDecl);
@@ -1167,7 +1167,8 @@ ExprResult Sema::BuildInstanceMessage(Expr *Receiver,
             if (OCIType->qual_empty()) {
               Method = LookupInstanceMethodInGlobalPool(Sel,
                                                  SourceRange(LBracLoc, RBracLoc));
-              forwardClass = OCIType->getInterfaceDecl()->isForwardDecl();
+              if (OCIType->getInterfaceDecl()->isForwardDecl())
+                forwardClass = OCIType->getInterfaceDecl();
               if (Method && !forwardClass)
                 Diag(Loc, diag::warn_maynot_respond)
                   << OCIType->getInterfaceDecl()->getIdentifier() << Sel;
index 8e03e1c4c288eba55c7a4914a407c5ed6a94acef..1d07a49e619dbe555a6f4365fe746fe10865089f 100644 (file)
@@ -27,7 +27,7 @@
 @end
 
 
-@class C;
+@class C;      // expected-note 5 {{forward class is declared here}}
 
 void test(C *c) {
   [c depInA]; // expected-warning {{'depInA' maybe deprecated because receiver type is unknown}}