xref: /llvm-project/clang/test/SemaTemplate/template-friend-definition-in-template.cpp (revision 921b45a855f09afe99ea9c0c173794ee4ccd5872)
1 // RUN: %clang_cc1 -fsyntax-only -verify %s
2 // expected-no-diagnostics
3 
4 template <class F1> int foo1(F1 X1);
5 
6 template <int A1> struct A {
foo1(F2 X2)7   template <class F2> friend int foo1(F2 X2) {
8     return A1;
9   }
10 };
11 
12 template struct A<1>;
main()13 int main() {
14   foo1(1.0);
15 }
16 
17 template <class F1> int foo2(F1 X1);
18 
19 template <int A1> struct B {
foo2(F2 X2)20   template <class F2> friend int foo2(F2 X2) {
21     return A1;
22   }
23 };
24 
25 template struct B<1>;
26 template int foo2<float>(float X1);
27