2010-04-10 03:03:51 +08:00
|
|
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
|
2009-03-27 14:03:27 +08:00
|
|
|
namespace T1 {
|
|
|
|
|
|
|
|
class A { };
|
2010-02-10 17:31:12 +08:00
|
|
|
class B : private A { }; // expected-note {{declared private here}}
|
2009-03-27 14:03:27 +08:00
|
|
|
|
|
|
|
void f(B* b) {
|
2010-03-10 19:27:22 +08:00
|
|
|
A *a = b; // expected-error{{cannot cast 'T1::B' to its private base class 'T1::A'}}
|
2009-03-27 14:03:27 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace T2 {
|
|
|
|
|
|
|
|
class A { };
|
2010-02-10 17:31:12 +08:00
|
|
|
class B : A { }; // expected-note {{implicitly declared private here}}
|
2009-03-27 14:03:27 +08:00
|
|
|
|
|
|
|
void f(B* b) {
|
2010-03-10 19:27:22 +08:00
|
|
|
A *a = b; // expected-error {{cannot cast 'T2::B' to its private base class 'T2::A'}}
|
2009-03-27 14:03:27 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace T3 {
|
|
|
|
|
|
|
|
class A { };
|
|
|
|
class B : public A { };
|
|
|
|
|
|
|
|
void f(B* b) {
|
|
|
|
A *a = b;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace T4 {
|
|
|
|
|
|
|
|
class A {};
|
|
|
|
|
|
|
|
class B : private virtual A {};
|
|
|
|
class C : public virtual A {};
|
|
|
|
|
|
|
|
class D : public B, public C {};
|
|
|
|
|
|
|
|
void f(D *d) {
|
|
|
|
// This takes the D->C->B->A path.
|
|
|
|
A *a = d;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2009-03-28 03:01:12 +08:00
|
|
|
|
|
|
|
namespace T5 {
|
|
|
|
class A {};
|
|
|
|
|
|
|
|
class B : private A {
|
|
|
|
void f(B *b) {
|
|
|
|
A *a = b;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace T6 {
|
|
|
|
class C;
|
|
|
|
|
2010-05-28 12:34:55 +08:00
|
|
|
class A {}; // expected-note{{member is declared here}}
|
2009-03-28 03:01:12 +08:00
|
|
|
|
2010-03-19 07:49:19 +08:00
|
|
|
class B : private A { // expected-note {{declared private here}} expected-note {{constrained by private inheritance here}}
|
2009-03-28 03:01:12 +08:00
|
|
|
void f(C* c);
|
|
|
|
};
|
|
|
|
|
|
|
|
class C : public B {
|
|
|
|
void f(C *c) {
|
2010-03-19 07:49:19 +08:00
|
|
|
A* a = c; // expected-error {{cannot cast 'T6::C' to its private base class 'T6::A'}} \
|
|
|
|
// expected-error {{'A' is a private member of 'T6::A'}}
|
2009-03-28 03:01:12 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
void B::f(C *c) {
|
|
|
|
A *a = c;
|
|
|
|
}
|
|
|
|
}
|
2010-02-10 17:31:12 +08:00
|
|
|
|
|
|
|
namespace T7 {
|
|
|
|
class A {};
|
|
|
|
class B : public A {};
|
|
|
|
class C : private B {
|
|
|
|
void f(C *c) {
|
|
|
|
A* a = c; // okay
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|