In -fdelayed-template-parsing mode, reenter every scope when late parsing a templated function; (Not just the template parameter scope as previously). Also enter the scope stack in the correct order.

Otherwise this breaks some invariant during name lookup especially when dealing with shadowed declaration

Fix PR11931.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151140 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/Parser/DelayedTemplateParsing.cpp b/test/Parser/DelayedTemplateParsing.cpp
index 7fa87d9..9737c73 100644
--- a/test/Parser/DelayedTemplateParsing.cpp
+++ b/test/Parser/DelayedTemplateParsing.cpp
@@ -63,3 +63,30 @@
 
 }
 
+
+namespace PR11931 {
+
+template <typename RunType>
+struct BindState;
+
+  template<>
+struct BindState<void(void*)> {
+  static void Run() { }
+};
+
+class Callback {
+public:
+  typedef void RunType();
+
+  template <typename RunType>
+  Callback(BindState<RunType> bind_state) {
+    BindState<RunType>::Run();
+  }
+};
+
+
+Callback Bind() {
+  return Callback(BindState<void(void*)>());
+}
+
+}