]>
Commit | Line | Data |
---|---|---|
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 |
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; | |
e335c541 AO |
22 | |
23 | class B { | |
24 | protected: | |
d6479fe7 | 25 | int i; // ERROR - in this context |
6a629cac | 26 | static int j; |
e335c541 AO |
27 | }; |
28 | ||
29 | class 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 | ||
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; | |
e335c541 AO |
47 | }; |
48 | ||
f2d9afec JM |
49 | B b; |
50 | D d; | |
51 | ||
e335c541 AO |
52 | void 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 | |
60 | template <typename T> | |
61 | void 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 | ||
69 | template void g<int>(); | |
70 | ||
71 | void 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 | ||
79 | template <typename T> | |
80 | void 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 | ||
88 | template struct R<double>; |