3 // Copyright (C) 2003 Free Software Foundation
4 // Contributed by Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
6 // Member function of class template as friend
7 // Erroneous case: mismatch during specialization
9 template <class T> struct A {
10 template <class U> void f(U);
14 template <T t> void j();
18 int ii; // { dg-error "private" }
19 template <class U> template <class V>
20 friend void A<U>::f(V);
21 template <class U> friend void A<U>::g();
22 template <class U> friend void A<U>::h();
23 template <class U> friend void A<U>::i(int);
24 template <class U> template <U t>
25 friend void A<U>::j();
28 template <class T> struct A<T*> {
30 template <class U> void g();
33 template <int> void j();
36 template <class T> void A<T*>::f(int)
39 c.ii = 0; // { dg-error "context" }
42 template <class T> template <class U> void A<T*>::g()
45 c.ii = 0; // { dg-error "context" }
48 template <class T> int A<T*>::h()
51 c.ii = 0; // { dg-error "context" }
54 template <class T> void A<T*>::i(char)
57 c.ii = 0; // { dg-error "context" }
60 template <class T> template <int> void A<T*>::j()
63 c.ii = 0; // { dg-error "context" }
66 template <> struct A<char> {
68 template <class U> void g();
71 template <int> void j();
77 c.ii = 0; // { dg-error "context" }
80 template <class U> void A<char>::g()
83 c.ii = 0; // { dg-error "context" }
86 template <> void A<char>::g<int>()
89 c.ii = 0; // { dg-error "context" }
95 c.ii = 0; // { dg-error "context" }
101 c.ii = 0; // { dg-error "context" }
104 template <int> void A<char>::j()
107 c.ii = 0; // { dg-error "context" }
110 template <> void A<char>::j<0>()
113 c.ii = 0; // { dg-error "context" }
119 a1.f(0); // { dg-message "instantiated" }
120 a1.g<char>(); // { dg-message "instantiated" }
121 a1.g<int>(); // { dg-message "instantiated" }
122 a1.h(); // { dg-message "instantiated" }
123 a1.i('a'); // { dg-message "instantiated" }
124 a1.j<1>(); // { dg-message "instantiated" }
127 a2.g<char>(); // { dg-message "instantiated" }
131 a2.j<1>(); // { dg-message "instantiated" }