Debian Codegraph @

gcc/testsuite/g++.old-deja/g++.other/friend1.C

raw
1 // { dg-do assemble }
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: <[email protected]>
6 // <[email protected]>
7 // <[email protected]>
8 // <[email protected]> <[email protected]>
9 // From: Alexandre Oliva <[email protected]>
10 // Date: 06 Mar 1998 01:43:18 -0300
11
12 template <int*>
13 class X {};
14
15 template <typename T>
16 void g();
17
18 struct S;
19
20 template <typename T>
21 struct R;
22
23 class B {
24 protected:
25 int i; // { dg-message "" } protected
26 static int j;
27 };
28
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;
36 };
37
38 struct S {
39 void h();
40 X<&B::j> x;
41 };
42
43 template <typename T>
44 struct R {
45 void h();
46 X<&B::j> x;
47 };
48
49 B b;
50 D d;
51
52 void f()
53 {
54 b.i = 3; // { dg-error "" } in this context
55 d.i = 4;
56 B::j = 5;
57 D::j = 6;
58 }
59
60 template <typename T>
61 void g()
62 {
63 b.i = 3; // { dg-error "" } in this context
64 d.i = 4;
65 B::j = 5;
66 D::j = 6;
67 }
68
69 template void g<int>();
70
71 void S::h()
72 {
73 b.i = 3; // { dg-error "" } in this context
74 d.i = 4;
75 B::j = 5;
76 D::j = 6;
77 }
78
79 template <typename T>
80 void R<T>::h()
81 {
82 b.i = 3; // { dg-error "" } in this context
83 d.i = 4;
84 B::j = 5;
85 D::j = 6;
86 }
87
88 template struct R<double>;