Debian Codegraph @

gcc/testsuite/g++.dg/template/friend81.C

raw
1 // PR c++/112288
2 // { dg-do link }
3
4 template<class T> struct A;
5 template<class T> struct B;
6
7 A<int>* a;
8 B<int>* b;
9
10 template<class T>
11 struct B {
12 template<class U>
13 friend int f(A<T>*, B*, U);
14 };
15
16 template struct B<int>; // f declared
17 int n = f(a, b, 0); // f<int> specialized
18
19 template<class T>
20 struct A {
21 template<class U>
22 friend int f(A*, B<T>*, U) { return 42; }
23 };
24
25 template struct A<int>; // f defined, need to make existing f<int> point to defn
26 int m = f(a, b, 0); // reuses existing specialization f<int>
27
28 int main() { }