Clang erroneously rejects the following code because it does not find the default argument for makeType :
namespace n { template <class> struct Type { template <class T> friend Type<T> makeType(); }; template <class T = void> Type<T> makeType(); void f() { Type<void> t; n::makeType<>(); // Error, lookup finds wrong version of makeType } } // end namespace n
The problem is that during instantiation of Type<void> on the previous line the default template argument version of makeType is incorrectly swapped out of DeclContext::LookupPtr for the friend version. This patch fixes that by disallowing the swap in NamedDecl::declarationReplaces().
This patch looks like it's a fix for PR10856, PR18038, PR20877, and PR26962.