Merge from mainline (167278:168000).
[official-gcc/graphite-test-results.git] / gcc / testsuite / g++.dg / template / memfriend11.C
blobe33e99bdc51bdcc701cb4387db2f147582a5975f
1 // { dg-do compile }
3 // Copyright (C) 2004 Free Software Foundation
4 // Contributed by Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
6 // Nested class template of class template as friend
8 template<class T> struct A
10   template <T t> struct B
11   {
12     void f();
13   };
16 class C {
17   int i;
18   template<class T> template <T t> friend struct A<T>::B;
21 template<class T> struct A<T*>
23   template <T* t> struct B
24   {
25     void f();
26   };
29 template<> struct A<char>
31   template <char t> struct B
32   {
33     void f();
34   };
37 template<class T> template <T t> void A<T>::B<t>::f()
39   C c;
40   c.i = 0;
43 template<class T> template <T* t> void A<T*>::B<t>::f()
45   C c;
46   c.i = 0;
49 template <char t> void A<char>::B<t>::f()
51   C c;
52   c.i = 0;
55 template <> void A<char>::B<'b'>::f()
57   C c;
58   c.i = 0;
61 int d2 = 0;
63 int main()
65   A<int>::B<0> b1;
66   b1.f();
67   A<int *>::B<&d2> b2;
68   b2.f();
69   A<char>::B<'a'> b3;
70   b3.f();
71   A<char>::B<'b'> b4;
72   b4.f();