summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/template/friend4.C
blob: fabf3375bd2152c1039441809bbf775baceffee6 (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
45
46
// { dg-do compile }

// Copyright (C) 2002 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 18 Dec 2001 <nathan@codesourcery.com>

// PR 109, dependent member friends

struct B
{
  static int foo ();
  struct N
  {
    static int bar ();
  };
};


template <class T>
class A
{
  friend int T::foo ();
  friend int T::N::bar ();
  
  private:
  static int m;
};

template <class T>
class C
{
  friend struct T::N;

  private:
  static int m;
};


int B::foo ()
{
  return A<B>::m;
}

int B::N::bar ()
{
  return A<B>::m + C<B>::m;
}