Richard, this implements what you proposed in https://llvm.org/bugs/show_bug.cgi?id=25223 , hopefully in the correct way.
This is what we emit now:
template.cpp:7:3: error: missing template argument list for class template 'X'
T X::foo(void)
^ X<T, Q>
template.cpp:2:7: note: 'X' declared here
class X {
^
1 error generated.
I will tackle the case where we emit a terrible diagnostic for ambigous lookup separately.
This isn't quite the right thing to do; it's looking at the template parameters of the class template rather than the current template parameters, and they could be quite different. Instead, you should do something like: