// Substitute the deduced template arguments into the function template
// declaration to produce the function template specialization.
+ DeclContext *Owner = FunctionTemplate->getDeclContext();
+ if (FunctionTemplate->getFriendObjectKind())
+ Owner = FunctionTemplate->getLexicalDeclContext();
Specialization = cast_or_null<FunctionDecl>(
- SubstDecl(FunctionTemplate->getTemplatedDecl(),
- FunctionTemplate->getDeclContext(),
+ SubstDecl(FunctionTemplate->getTemplatedDecl(), Owner,
MultiLevelTemplateArgumentList(*DeducedArgumentList)));
if (!Specialization)
return TDK_SubstitutionFailure;
};
}
+namespace FriendTemplateDefinition {
+ template<unsigned > struct int_c { };
+
+ template<typename T>
+ struct X {
+ template<unsigned N>
+ friend void f(X, int_c<N>) {
+ int value = N;
+ };
+ };
+
+ void test_X(X<int> x, int_c<5> i5) {
+ f(x, i5);
+ }
+}