When looking for a tag name via unqualified name lookup, only look in
scopes where the name would be considered a redeclaration if we know
that we're declaring or defining that tag.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63647 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index 39747b6..66b72ec 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -2829,7 +2829,8 @@
     // FIXME: We're looking into outer scopes here, even when we
     // shouldn't be. Doing so can result in ambiguities that we
     // shouldn't be diagnosing.
-    LookupResult R = LookupName(S, Name, LookupTagName);
+    LookupResult R = LookupName(S, Name, LookupTagName,
+                                /*RedeclarationOnly=*/(TK != TK_Reference));
     if (R.isAmbiguous()) {
       DiagnoseAmbiguousLookup(R, Name, NameLoc);
       // FIXME: This is not best way to recover from case like: