Improve error recovery for missing 'template' keyword in contexts where the
template is valid with or without it (with different meanings).

If we see "dependent.x<...", and what follows the '<' is a valid expression,
we must parse the '<' as a comparison rather than a template angle bracket.
When we later come to instantiate, if we find that the LHS of the '<' actually
names an overload set containing function templates, produce a diagnostic
suggesting that the 'template' keyword was missed rather than producing a
mysterious diagnostic saying that the function must be called (and pointing
at what looks to already be a function call!).

llvm-svn: 304852
diff --git a/clang/test/SemaTemplate/dependent-template-recover.cpp b/clang/test/SemaTemplate/dependent-template-recover.cpp
index 3c01f65..ac16230 100644
--- a/clang/test/SemaTemplate/dependent-template-recover.cpp
+++ b/clang/test/SemaTemplate/dependent-template-recover.cpp
@@ -17,6 +17,28 @@
   }
 };
 
+struct MrsBadcrumble {
+  friend MrsBadcrumble operator<(void (*)(int), MrsBadcrumble);
+  friend void operator>(MrsBadcrumble, int);
+} mb;
+
+template<int N, typename T> void f(T t) {
+  t.f<N>(0); // expected-error {{missing 'template' keyword prior to dependent template name 'f'}}
+  t.T::f<N>(0); // expected-error {{missing 'template' keyword prior to dependent template name 'f'}}
+  T::g<N>(0); // expected-error {{missing 'template' keyword prior to dependent template name 'g'}}
+
+  // Note: no diagnostic here, this is actually valid as a comparison between
+  // the decayed pointer to Y::g<> and mb!
+  T::g<mb>(0);
+}
+
+struct Y {
+  template <int> void f(int);
+  template <int = 0> static void g(int); // expected-warning 0-1{{extension}}
+};
+void q() { void (*p)(int) = Y::g; }
+template void f<0>(Y); // expected-note {{in instantiation of}}
+
 namespace PR9401 {
   // From GCC PR c++/45558
   template <typename S, typename T>