PR18246: When performing template argument deduction to decide which template
is specialized by an explicit specialization, start from the first declaration
in case we've got a member of a class template (redeclarations might not number
the template parameters the same way).

Our recover here is still far from ideal.

llvm-svn: 197305
diff --git a/clang/test/SemaTemplate/explicit-specialization-member.cpp b/clang/test/SemaTemplate/explicit-specialization-member.cpp
index 9ddbc04..07d7389 100644
--- a/clang/test/SemaTemplate/explicit-specialization-member.cpp
+++ b/clang/test/SemaTemplate/explicit-specialization-member.cpp
@@ -28,3 +28,22 @@
   };
   template<> struct S<int>::U { static const int n = sizeof(int); }; // expected-error {{explicit specialization of 'U' after instantiation}}
 }
+
+namespace PR18246 {
+  template<typename T>
+  class Baz {
+  public:
+    template<int N> void bar();
+  };
+
+  template<typename T>
+  template<int N>
+  void Baz<T>::bar() {
+  }
+
+  // FIXME: Don't suggest the 'template<>' correction here, because this cannot
+  // be an explicit specialization.
+  template<typename T>
+  void Baz<T>::bar<0>() { // expected-error {{requires 'template<>'}}
+  }
+}