2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / testsuite / g++.old-deja / g++.other / friend1.C
blob56236ab33a6367c686be24a2df84cbb51843c231
1 // { dg-do assemble  }
2 // f() should be able to access B::j, as of FDIS [class.protected]/1
4 // Subject: Re: [bug] Inheritance and friend access control broken
5 // References: <199803032141.WAA09332@piano.dptmaths.ens-cachan.fr>
6 // <orhg5ff544.fsf@iguacu.dcc.unicamp.br>
7 // <199803041125.MAA06937@cor.dptmaths.ens-cachan.fr>
8 // <orn2f6ek92.fsf@iguacu.dcc.unicamp.br> <19980304102900.46897@dgii.com>
9 // From: Alexandre Oliva <oliva@dcc.unicamp.br>
10 // Date: 06 Mar 1998 01:43:18 -0300
12 template <int*>
13 class X {};
15 template <typename T>
16 void g();
18 struct S;
20 template <typename T>
21 struct R;
23 class B {
24 protected:
25   int i; // { dg-error "" } in this context
26   static int j;
29 class D : public B {
30   friend void f();
31   template <typename T>
32   friend void g();
33   friend struct S;
34   template <typename T>
35   friend struct R;
38 struct S {
39   void h();
40   X<&B::j> x;
43 template <typename T>
44 struct R {
45   void h();
46   X<&B::j> x;
49 B b;
50 D d;
52 void f()
54     b.i = 3; // { dg-error "" } protected
55     d.i = 4;
56     B::j = 5;
57     D::j = 6;
60 template <typename T>
61 void g()
63     b.i = 3; // { dg-error "" } protected
64     d.i = 4;
65     B::j = 5;
66     D::j = 6;
69 template void g<int>();
71 void S::h()
73   b.i = 3; // { dg-error "" } protected
74   d.i = 4;
75   B::j = 5;
76   D::j = 6;
79 template <typename T>
80 void R<T>::h() 
82   b.i = 3; // { dg-error "" } protected
83   d.i = 4;
84   B::j = 5;
85   D::j = 6;
88 template struct R<double>;