Revisit PR10177: don't instantiate a variable if it's only referenced in a
dependent context and can't be used in a constant expression.

Per C++ [temp.inst]p2, "the instantiation of a static data member does not
occur unless the static data member is used in a way that requires the
definition to exist".

This doesn't /quite/ match that, as we still instantiate static data members
that are usable in constant expressions even if the use doesn't require a
definition. A followup patch will fix that for both variables and functions.

llvm-svn: 291295
diff --git a/clang/test/SemaCXX/PR10177.cpp b/clang/test/SemaCXX/PR10177.cpp
index 9286e29..59630be 100644
--- a/clang/test/SemaCXX/PR10177.cpp
+++ b/clang/test/SemaCXX/PR10177.cpp
@@ -24,6 +24,13 @@
   (void)class_ref<int, int&, U<2>::a>(); // expected-note {{here}}
 };
 
+template<typename T>
+void not_instantiated() {
+  // These cases (arguably) do not require instantiation of U<i>::a.
+  (void)alias_ref<int, int&, U<3>::a>();
+  (void)func_ref<int, int&, U<4>::a>();
+  (void)class_ref<int, int&, U<5>::a>();
+};
 
 template<int N>
 void fi() {
@@ -33,7 +40,7 @@
 };
 
 int main() {
-  f<int>();   // NOTE: Non-dependent name uses are type-checked at template definition time.
+  f<int>();   // expected-note 3{{here}}
   fi<10>();   // expected-note 3{{here}}
 }