'extern' variables in functions don't shadow externs in global scope. Fixes rdar://8883302, this time for C++ as well.

llvm-svn: 130157
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index d07bd4b..200f8ce 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -3664,10 +3664,11 @@
     return;
 
   // Don't diagnose declarations at file scope.
-  DeclContext *NewDC = D->getDeclContext();
-  if (NewDC->isFileContext())
+  if (D->hasGlobalStorage())
     return;
-  
+
+  DeclContext *NewDC = D->getDeclContext();
+
   // Only diagnose if we're shadowing an unambiguous field or variable.
   if (R.getResultKind() != LookupResult::Found)
     return;
@@ -3684,17 +3685,6 @@
 
   if (VarDecl *shadowedVar = dyn_cast<VarDecl>(ShadowedDecl))
     if (shadowedVar->isExternC()) {
-      // Don't warn for this case:
-      //
-      // @code
-      // extern int bob;
-      // void f() {
-      //   extern int bob;
-      // }
-      // @endcode
-      if (D->isExternC())
-        return;
-
       // For shadowing external vars, make sure that we point to the global
       // declaration, not a locally scoped extern declaration.
       for (VarDecl::redecl_iterator