When determining whether to try evaluating the initializer of a variable, check
whether the initializer is value-dependent rather than whether we are in a
dependent context. This allows us to detect some errors sooner, and fixes a
crash-on-invalid if a dependent type leaks out to a non-dependent context in
error recovery.

llvm-svn: 166898
diff --git a/clang/test/SemaCXX/cxx11-crashes.cpp b/clang/test/SemaCXX/cxx11-crashes.cpp
index 66b182b..bd51af1 100644
--- a/clang/test/SemaCXX/cxx11-crashes.cpp
+++ b/clang/test/SemaCXX/cxx11-crashes.cpp
@@ -62,3 +62,15 @@
 }
 
 }
+
+namespace b6981007 {
+  struct S {}; // expected-note 3{{candidate}}
+  void f() {
+    S s(1, 2, 3); // expected-error {{no matching}}
+    for (auto x : s) {
+      // We used to attempt to evaluate the initializer of this variable,
+      // and crash because it has an undeduced type.
+      const int &n(x);
+    }
+  }
+}