]> gcc.gnu.org Git - gcc.git/blame - gcc/testsuite/g++.old-deja/g++.other/friend1.C
spec4.C: Remove stray semicolon.
[gcc.git] / gcc / testsuite / g++.old-deja / g++.other / friend1.C
CommitLineData
e335c541
AO
1// Build don't link:
2// f() should be able to access B::j, as of FDIS [class.protected]/1
3
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
11
6a629cac
MM
12template <int*>
13class X {};
14
15template <typename T>
16void g();
17
18struct S;
19
20template <typename T>
21struct R;
e335c541
AO
22
23class B {
24protected:
d6479fe7 25 int i; // ERROR - in this context
6a629cac 26 static int j;
e335c541
AO
27};
28
29class D : public B {
6a629cac
MM
30 friend void f();
31 template <typename T>
32 friend void g();
33 friend struct S;
34 template <typename T>
35 friend struct R;
36};
37
38struct S {
39 void h();
40 X<&B::j> x;
41};
42
43template <typename T>
44struct R {
45 void h();
46 X<&B::j> x;
e335c541
AO
47};
48
f2d9afec
JM
49B b;
50D d;
51
e335c541
AO
52void f()
53{
f2d9afec
JM
54 b.i = 3; // ERROR - protected
55 d.i = 4;
6a629cac 56 B::j = 5;
e335c541
AO
57 D::j = 6;
58}
6a629cac
MM
59
60template <typename T>
61void g()
62{
f2d9afec
JM
63 b.i = 3; // ERROR - protected
64 d.i = 4;
6a629cac
MM
65 B::j = 5;
66 D::j = 6;
67}
68
69template void g<int>();
70
71void S::h()
72{
f2d9afec
JM
73 b.i = 3; // ERROR - protected
74 d.i = 4;
6a629cac
MM
75 B::j = 5;
76 D::j = 6;
77}
78
79template <typename T>
80void R<T>::h()
81{
f2d9afec
JM
82 b.i = 3; // ERROR - protected
83 d.i = 4;
6a629cac
MM
84 B::j = 5;
85 D::j = 6;
86}
87
88template struct R<double>;
This page took 1.521392 seconds and 5 git commands to generate.