-Wshadow should only warn about parameter declarations when we're
entering a function or block definition, not on every single declaration.
Unfortunately we don't have previous-lookup results around when it's time
to make this decision, so we have to redo the lookup.  The alternative is
to use delayed diagnostics.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99172 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index fe6f3b9..007d625 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -6905,13 +6905,21 @@
                                CurBlock->Params.size());
   CurBlock->TheDecl->setIsVariadic(CurBlock->isVariadic);
   ProcessDeclAttributes(CurScope, CurBlock->TheDecl, ParamInfo);
+
+  bool ShouldCheckShadow =
+    Diags.getDiagnosticLevel(diag::warn_decl_shadow) != Diagnostic::Ignored;
+
   for (BlockDecl::param_iterator AI = CurBlock->TheDecl->param_begin(),
          E = CurBlock->TheDecl->param_end(); AI != E; ++AI) {
     (*AI)->setOwningFunction(CurBlock->TheDecl);
 
     // If this has an identifier, add it to the scope stack.
-    if ((*AI)->getIdentifier())
+    if ((*AI)->getIdentifier()) {
+      if (ShouldCheckShadow)
+        CheckShadow(CurBlock->TheScope, *AI);
+
       PushOnScopeChains(*AI, CurBlock->TheScope);
+    }
   }
 
   // Check for a valid sentinel attribute on this block.