When performing template argument deduction given a function argument
of incomplete array type, attempt to complete the array type. This was
made much easier by Chandler's addition of RequireCompleteExprType(),
which I've tweaked (slightly) to improve the consistency of the
DeclRefExpr. Fixes PR7985.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132530 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/SemaTemplate/instantiate-init.cpp b/test/SemaTemplate/instantiate-init.cpp
index d5711dd..ce2c163 100644
--- a/test/SemaTemplate/instantiate-init.cpp
+++ b/test/SemaTemplate/instantiate-init.cpp
@@ -73,3 +73,26 @@
 
   int x = S<int>::f();
 }
+
+namespace PR7985 {
+  template<int N> struct integral_c { };
+
+  template <typename T, int N>
+  integral_c<N> array_lengthof(T (&x)[N]) { return integral_c<N>(); }
+
+  struct Data {
+    int x;
+  };
+
+  template<typename T>
+  struct Description {
+    static const Data data[];
+  };
+
+  template<typename T>
+  const Data Description<T>::data[] = {{ 0 }};
+
+  void test() {
+    integral_c<1> ic1 = array_lengthof(Description<int>::data);
+  }
+}