Revert r284008. This is us to fail to instantiate static data members in some
cases. I'm working on reducing a testcase.

llvm-svn: 284081
diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
index 911bc51..09068d7 100644
--- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -4068,10 +4068,6 @@
       PrettyDeclStackTraceEntry CrashInfo(*this, Var, SourceLocation(),
                                           "instantiating variable initializer");
 
-      // The instantiation is visible here, even if it was first declared in an
-      // unimported module.
-      Var->setHidden(false);
-
       // If we're performing recursive template instantiation, create our own
       // queue of pending implicit instantiations that we will instantiate
       // later, while we're still within our own instantiation context.
@@ -4120,17 +4116,33 @@
     Def = PatternDecl->getDefinition();
   }
 
-  TemplateSpecializationKind TSK = Var->getTemplateSpecializationKind();
+  // FIXME: Check that the definition is visible before trying to instantiate
+  // it. This requires us to track the instantiation stack in order to know
+  // which definitions should be visible.
 
   // If we don't have a definition of the variable template, we won't perform
   // any instantiation. Rather, we rely on the user to instantiate this
   // definition (or provide a specialization for it) in another translation
   // unit.
-  if (!Def && !DefinitionRequired) {
-    if (TSK == TSK_ExplicitInstantiationDefinition) {
+  if (!Def) {
+    if (DefinitionRequired) {
+      if (VarSpec) {
+        Diag(PointOfInstantiation,
+             diag::err_explicit_instantiation_undefined_var_template) << Var;
+        Var->setInvalidDecl();
+      }
+      else
+        Diag(PointOfInstantiation,
+             diag::err_explicit_instantiation_undefined_member)
+            << 2 << Var->getDeclName() << Var->getDeclContext();
+      Diag(PatternDecl->getLocation(),
+           diag::note_explicit_instantiation_here);
+    } else if (Var->getTemplateSpecializationKind()
+                 == TSK_ExplicitInstantiationDefinition) {
       PendingInstantiations.push_back(
         std::make_pair(Var, PointOfInstantiation));
-    } else if (TSK == TSK_ImplicitInstantiation) {
+    } else if (Var->getTemplateSpecializationKind()
+                 == TSK_ImplicitInstantiation) {
       // Warn about missing definition at the end of translation unit.
       if (AtEndOfTU && !getDiagnostics().hasErrorOccurred()) {
         Diag(PointOfInstantiation, diag::warn_var_template_missing)
@@ -4139,20 +4151,12 @@
         if (getLangOpts().CPlusPlus11)
           Diag(PointOfInstantiation, diag::note_inst_declaration_hint) << Var;
       }
-      return;
     }
 
+    return;
   }
 
-  // FIXME: We need to track the instantiation stack in order to know which
-  // definitions should be visible within this instantiation.
-  // FIXME: Produce diagnostics when Var->getInstantiatedFromStaticDataMember().
-  if (DiagnoseUninstantiableTemplate(PointOfInstantiation, Var,
-                                     /*InstantiatedFromMember*/false,
-                                     PatternDecl, Def, TSK,
-                                     /*Complain*/DefinitionRequired))
-    return;
-
+  TemplateSpecializationKind TSK = Var->getTemplateSpecializationKind();
 
   // Never instantiate an explicit specialization.
   if (TSK == TSK_ExplicitSpecialization)