Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / SemaCXX / access-base-class.cpp
blob47d0f02ec545c892545a342fd2646f1300902f5c
1 // RUN: %clang_cc1 -fsyntax-only -verify %s
2 namespace T1 {
4 class A { };
5 class B : private A { }; // expected-note {{declared private here}}
7 void f(B* b) {
8 A *a = b; // expected-error{{cannot cast 'B' to its private base class 'A'}}
13 namespace T2 {
15 class A { };
16 class B : A { }; // expected-note {{implicitly declared private here}}
18 void f(B* b) {
19 A *a = b; // expected-error {{cannot cast 'B' to its private base class 'A'}}
24 namespace T3 {
26 class A { };
27 class B : public A { };
29 void f(B* b) {
30 A *a = b;
35 namespace T4 {
37 class A {};
39 class B : private virtual A {};
40 class C : public virtual A {};
42 class D : public B, public C {};
44 void f(D *d) {
45 // This takes the D->C->B->A path.
46 A *a = d;
51 namespace T5 {
52 class A {};
54 class B : private A {
55 void f(B *b) {
56 A *a = b;
58 };
61 namespace T6 {
62 class C;
64 class A {}; // expected-note{{member is declared here}}
66 class B : private A { // expected-note {{declared private here}} expected-note {{constrained by private inheritance here}}
67 void f(C* c);
70 class C : public B {
71 void f(C *c) {
72 A* a = c; // expected-error {{cannot cast 'C' to its private base class 'A'}} \
73 // expected-error {{'A' is a private member of 'T6::A'}}
77 void B::f(C *c) {
78 A *a = c;
82 namespace T7 {
83 class A {};
84 class B : public A {};
85 class C : private B {
86 void f(C *c) {
87 A* a = c; // okay
92 namespace T8 {
93 template <int>
94 struct flag {
95 static constexpr bool value = true;
98 template <class T>
99 struct trait : flag<sizeof(T)> {}; // expected-note 2{{here}}
101 template <class T, bool Inferred = trait<T>::value> // expected-note {{here}}
102 struct a {};
104 template <class T>
105 class b {
106 a<T> x; // expected-note {{here}}
107 using U = a<T>;
110 template <int>
111 struct Impossible {
112 static_assert(false, ""); // expected-error {{static assertion failed}}
115 // verify "no member named 'value'" bogus diagnostic is not emitted.
116 trait<b<Impossible<0>>>::value; // expected-note {{here}}
117 } // namespace T8