Check in LLVM r95781.
diff --git a/test/SemaTemplate/instantiate-local-class.cpp b/test/SemaTemplate/instantiate-local-class.cpp
new file mode 100644
index 0000000..768eb21
--- /dev/null
+++ b/test/SemaTemplate/instantiate-local-class.cpp
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -verify %s
+template<typename T>
+void f0() {
+  struct X;
+  typedef struct Y {
+    T (X::* f1())(int) { return 0; }
+  } Y2;
+
+  Y2 y = Y();
+}
+
+template void f0<int>();
+
+// PR5764
+namespace PR5764 {
+  class X {
+    template <typename T>
+    void Bar() {
+      typedef T ValueType;
+      class Y {
+        Y() { V = ValueType(); }
+
+        ValueType V;
+      };
+
+      Y y;
+    }
+  };
+
+  void test(X x) {
+    x.Bar<int>();
+  }
+}
+