summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/template/memfriend17.C
blob: 5e163fa477a85769ca47b886470e42028ddd0438 (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 }

// Origin: Giovanni Bajo <giovannibajo@libero.it>

// PR c++/13495: Nested class as template friend.

template<typename T>
class A{
public:
    class B
    {
        void func1(void);
        void func2(void);
    };
};

template<typename Q>
class F1
{
    friend class A<Q>::B;
    enum { foo = 0 };	// { dg-error "private" }
};

template<typename Q>
class F2
{
    template<typename T>
    friend class A<T>::B;
    enum { foo = 0 };
};

template <typename T>
void A<T>::B::func1(void)
{
    (void)F1<T>::foo;
    (void)F2<T>::foo;
}

template <typename T>
void A<T>::B::func2(void)
{
    (void)F1<T*>::foo;	// { dg-error "context" }
    (void)F2<T*>::foo;
}

template class A<int>;	// { dg-message "instantiated" }