summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.old-deja/g++.pt/friend44.C
blob: 1d2c1d1f9b67b06ed314ac6b2c320d86847f51dd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// { dg-do compile }
// Test that template friends referring to class template members are
// respected.


template <class T> struct A
{
  int f (T);
  struct AI {
    int f (T);
  };
};

class B
{
  template <class T> friend int A<T>::f (T);
  template <class T> friend struct A<T>::AI;
  int a;
public:
  B(): a(0) { }
};

template <class T> int A<T>::f (T)
{
  B b;
  return b.a;
}

template <class T> int A<T>::AI::f (T)
{
  B b;
  return b.a;
}

int main ()
{
  A<int> a;
  A<int>::AI ai;

  int r = a.f (0);
  r |= ai.f (0);

  return r;
}