Previously, when instantiating S<int>::mf below, we would emit a reference to the declaration of S<T2>::v<char>, when we really ought to make a new declaration for v in the template instantiation. This caused a variety of problems, since the variable template specialization that we were using was in a dependent context. The fix is to teach FindInstantiatedDecl to map the variable instantiation from the pattern to the instantiation.
Fixes llvm.org/PR42779.
template <class T2>
struct S {
template <class T1>
static constexpr int v = 0;
void mf() { v<char>; }
};
S<int> x;Thanks for taking a look!
Erik