1 // RUN: %clang_cc1 -fsyntax-only -verify %s
2 namespace T1 {
3 
4 class A { };
5 class B : private A { }; // expected-note {{declared private here}}
6 
f(B * b)7 void f(B* b) {
8   A *a = b; // expected-error{{cannot cast 'T1::B' to its private base class 'T1::A'}}
9 }
10 
11 }
12 
13 namespace T2 {
14 
15 class A { };
16 class B : A { }; // expected-note {{implicitly declared private here}}
17 
f(B * b)18 void f(B* b) {
19   A *a = b; // expected-error {{cannot cast 'T2::B' to its private base class 'T2::A'}}
20 }
21 
22 }
23 
24 namespace T3 {
25 
26 class A { };
27 class B : public A { };
28 
f(B * b)29 void f(B* b) {
30   A *a = b;
31 }
32 
33 }
34 
35 namespace T4 {
36 
37 class A {};
38 
39 class B : private virtual A {};
40 class C : public virtual A {};
41 
42 class D : public B, public C {};
43 
f(D * d)44 void f(D *d) {
45   // This takes the D->C->B->A path.
46   A *a = d;
47 }
48 
49 }
50 
51 namespace T5 {
52   class A {};
53 
54   class B : private A {
f(B * b)55     void f(B *b) {
56       A *a = b;
57     }
58   };
59 }
60 
61 namespace T6 {
62   class C;
63 
64   class A {}; // expected-note{{member is declared here}}
65 
66   class B : private A { // expected-note {{declared private here}} expected-note {{constrained by private inheritance here}}
67     void f(C* c);
68   };
69 
70   class C : public B {
f(C * c)71     void f(C *c) {
72       A* a = c; // expected-error {{cannot cast 'T6::C' to its private base class 'T6::A'}} \
73                 // expected-error {{'A' is a private member of 'T6::A'}}
74     }
75   };
76 
f(C * c)77   void B::f(C *c) {
78     A *a = c;
79   }
80 }
81 
82 namespace T7 {
83   class A {};
84   class B : public A {};
85   class C : private B {
f(C * c)86     void f(C *c) {
87       A* a = c; // okay
88     }
89   };
90 }
91 
92 namespace T8 {
93 template <int>
94 struct flag {
95   static constexpr bool value = true;
96 };
97 
98 template <class T>
99 struct trait : flag<sizeof(T)> {};
100 
101 template <class T, bool Inferred = trait<T>::value>
102 struct a {};
103 
104 template <class T>
105 class b {
106   a<T> x;
107   using U = a<T>;
108 };
109 
110 template <int>
111 struct Impossible {
112   static_assert(false, ""); // expected-error {{static_assert failed}}
113 };
114 
115 // verify "no member named 'value'" bogus diagnostic is not emitted.
116 trait<b<Impossible<0>>>::value;
117 } // namespace T8
118