Add some more tests for instantiation of declaration references. Also,
improve some error recovery with explicit template instantiation.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72484 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index 5e09851..d592cf6 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -3358,6 +3358,7 @@
     if (PrevDecl == 0) {
       Diag(NameLoc, diag::err_not_tag_in_scope) << Name << SS.getRange();
       Name = 0;
+      Invalid = true;
       goto CreateNewDecl;
     }
   } else if (Name) {
@@ -3629,7 +3630,8 @@
   New->setLexicalDeclContext(CurContext);
 
   // Set the access specifier.
-  SetMemberAccessSpecifier(New, PrevDecl, AS);
+  if (!Invalid)
+    SetMemberAccessSpecifier(New, PrevDecl, AS);
 
   if (TK == TK_Definition)
     New->startDefinition();