Diagnose unused exception parameters under a different warning group
(-Wunused-exception-parameter) than normal variables, since it's more
common to name and then ignore an exception parameter. This warning is
neither enabled by default nor by -Wall. Fixes <rdar://problem/7931045>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102931 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index eb91ec6..0e839a9 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -585,9 +585,14 @@
 
     // Diagnose unused variables in this scope.
     if (ShouldDiagnoseUnusedDecl(D) && 
-        S->getNumErrorsAtStart() == getDiagnostics().getNumErrors())
-      Diag(D->getLocation(), diag::warn_unused_variable) << D->getDeclName();
-    
+        S->getNumErrorsAtStart() == getDiagnostics().getNumErrors()) {
+      if (isa<VarDecl>(D) && cast<VarDecl>(D)->isExceptionVariable())
+        Diag(D->getLocation(), diag::warn_unused_exception_param)
+          << D->getDeclName();
+      else
+        Diag(D->getLocation(), diag::warn_unused_variable) 
+          << D->getDeclName();
+    }
     // Remove this name from our lexical scope.
     IdResolver.RemoveDecl(D);
   }