blob: f98437695efe342f31a28e25f38a15b97fa90c5f [file] [log] [blame]
Anders Carlssonc4f1e872009-03-27 06:03:27 +00001// RUN: clang-cc -fsyntax-only -verify %s
2namespace T1 {
3
4class A { };
5class B : private A { }; // expected-note {{'private' inheritance specifier here}}
6
7void f(B* b) {
8 A *a = b; // expected-error{{conversion from 'class T1::B' to inaccessible base class 'class T1::A'}} \
9 expected-error{{incompatible type initializing 'class T1::B *', expected 'class T1::A *'}}
10}
11
12}
13
14namespace T2 {
15
16class A { };
17class B : A { }; // expected-note {{inheritance is implicitly 'private'}}
18
19void f(B* b) {
20 A *a = b; // expected-error {{conversion from 'class T2::B' to inaccessible base class 'class T2::A'}} \
21 expected-error {{incompatible type initializing 'class T2::B *', expected 'class T2::A *'}}
22}
23
24}
25
26namespace T3 {
27
28class A { };
29class B : public A { };
30
31void f(B* b) {
32 A *a = b;
33}
34
35}
36
37namespace T4 {
38
39class A {};
40
41class B : private virtual A {};
42class C : public virtual A {};
43
44class D : public B, public C {};
45
46void f(D *d) {
47 // This takes the D->C->B->A path.
48 A *a = d;
49}
50
51}
Anders Carlssonf8080a32009-03-27 19:01:12 +000052
53namespace T5 {
54 class A {};
55
56 class B : private A {
57 void f(B *b) {
58 A *a = b;
59 }
60 };
61}
62
63namespace T6 {
64 class C;
65
66 class A {};
67
68 class B : private A { // expected-note {{'private' inheritance specifier here}}
69 void f(C* c);
70 };
71
72 class C : public B {
73 void f(C *c) {
74 A* a = c; // expected-error {{conversion from 'class T6::C' to inaccessible base class 'class T6::A'}} \
75 expected-error {{incompatible type initializing 'class T6::C *', expected 'class T6::A *'}}
76 }
77 };
78
79 void B::f(C *c) {
80 A *a = c;
81 }
82}