Fix crash when checking a dependently-typed reference that is
initialized from a non-value-dependent initializer.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@363622 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp
index aeb7963..bcb9f05 100644
--- a/lib/AST/Decl.cpp
+++ b/lib/AST/Decl.cpp
@@ -2282,7 +2282,7 @@
   //   declaration is encountered...
   const VarDecl *DefVD = nullptr;
   const Expr *Init = getAnyInitializer(DefVD);
-  if (!Init || Init->isValueDependent())
+  if (!Init || Init->isValueDependent() || getType()->isDependentType())
     return false;
   //   ... if it is a constexpr variable, or it is of reference type or of
   //   const-qualified integral or enumeration type, ...
diff --git a/test/SemaTemplate/dependent-expr.cpp b/test/SemaTemplate/dependent-expr.cpp
index 7195c9d..bb1e239 100644
--- a/test/SemaTemplate/dependent-expr.cpp
+++ b/test/SemaTemplate/dependent-expr.cpp
@@ -63,6 +63,14 @@
   };
 }
 
+namespace test6 {
+  template<typename T> T f() {
+    const T &v(0);
+    return v;
+  }
+  int use = f<int>();
+}
+
 namespace PR8795 {
   template <class _CharT> int test(_CharT t)
   {