c++: private inheritance access diagnostics fix [PR17314]
[gcc.git] / gcc / testsuite / g++.dg / tc1 / dr142.C
1 // { dg-do compile }
2 // Origin: Giovanni Bajo <giovannibajo at gcc dot gnu dot org>
3 // DR142: Injection-related errors in access example
4
5 class B {
6 public:
7 int mi;
8 static int si;
9 };
10
11 class D: private B { // { dg-message "declared" }
12 };
13
14 class DD: public D {
15 void f();
16 };
17
18 void DD::f() {
19 mi = 3; // { dg-error "within this context" }
20 si = 3; // { dg-error "within this context" }
21 ::B b;
22 b.mi = 3;
23 b.si = 3;
24 ::B::si = 3;
25 ::B* bp1 = this; // { dg-error "inaccessible base" }
26 ::B* bp2 = (::B*)this;
27 bp2->mi = 3;
28
29
30 B b2; // { dg-error "within this context" }
31 B::si = 3; // { dg-error "within this context" }
32 }