xref: /minix3/external/bsd/llvm/dist/clang/test/CXX/class.derived/class.member.lookup/p8.cpp (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -verify %s
2*f4a2713aSLionel Sambuc 
3*f4a2713aSLionel Sambuc // FIXME: Access control checks
4*f4a2713aSLionel Sambuc 
5*f4a2713aSLionel Sambuc namespace PR5820 {
6*f4a2713aSLionel Sambuc   // also <rdar://problem/7535045>
7*f4a2713aSLionel Sambuc   struct Base {
8*f4a2713aSLionel Sambuc     void Foo();
9*f4a2713aSLionel Sambuc     int Member;
10*f4a2713aSLionel Sambuc   };
11*f4a2713aSLionel Sambuc 
12*f4a2713aSLionel Sambuc   struct D1 : public Base {};
13*f4a2713aSLionel Sambuc   struct D2 : public Base {};
14*f4a2713aSLionel Sambuc 
15*f4a2713aSLionel Sambuc   struct Derived : public D1, public D2 {
16*f4a2713aSLionel Sambuc     void Inner();
17*f4a2713aSLionel Sambuc   };
18*f4a2713aSLionel Sambuc 
Test()19*f4a2713aSLionel Sambuc   void Test() {
20*f4a2713aSLionel Sambuc     Derived d;
21*f4a2713aSLionel Sambuc     d.D1::Foo();
22*f4a2713aSLionel Sambuc     d.D1::Member = 17;
23*f4a2713aSLionel Sambuc   }
24*f4a2713aSLionel Sambuc 
Inner()25*f4a2713aSLionel Sambuc   void Derived::Inner() {
26*f4a2713aSLionel Sambuc     D1::Foo();
27*f4a2713aSLionel Sambuc     D1::Member = 42;
28*f4a2713aSLionel Sambuc     this->D1::Foo();
29*f4a2713aSLionel Sambuc     this->D1::Member = 42;
30*f4a2713aSLionel Sambuc   }
31*f4a2713aSLionel Sambuc }
32*f4a2713aSLionel Sambuc 
33*f4a2713aSLionel Sambuc template<typename T>
34*f4a2713aSLionel Sambuc struct BaseT {
35*f4a2713aSLionel Sambuc   void Foo(); // expected-note{{found by ambiguous name lookup}}
36*f4a2713aSLionel Sambuc   int Member;
37*f4a2713aSLionel Sambuc };
38*f4a2713aSLionel Sambuc 
39*f4a2713aSLionel Sambuc template<typename T> struct Derived1T : BaseT<T> { };
40*f4a2713aSLionel Sambuc template<typename T> struct Derived2T : BaseT<T> { };
41*f4a2713aSLionel Sambuc 
42*f4a2713aSLionel Sambuc template<typename T>
43*f4a2713aSLionel Sambuc struct DerivedT : public Derived1T<T>, public Derived2T<T> {
44*f4a2713aSLionel Sambuc   void Inner();
45*f4a2713aSLionel Sambuc };
46*f4a2713aSLionel Sambuc 
47*f4a2713aSLionel Sambuc template<typename T>
Inner()48*f4a2713aSLionel Sambuc void DerivedT<T>::Inner() {
49*f4a2713aSLionel Sambuc   Derived1T<T>::Foo();
50*f4a2713aSLionel Sambuc   Derived2T<T>::Member = 42;
51*f4a2713aSLionel Sambuc   this->Derived1T<T>::Foo();
52*f4a2713aSLionel Sambuc   this->Derived2T<T>::Member = 42;
53*f4a2713aSLionel Sambuc   this->Foo(); // expected-error{{non-static member 'Foo' found in multiple base-class subobjects of type 'BaseT<int>'}}
54*f4a2713aSLionel Sambuc }
55*f4a2713aSLionel Sambuc 
56*f4a2713aSLionel Sambuc template<typename T>
Test(DerivedT<T> d)57*f4a2713aSLionel Sambuc void Test(DerivedT<T> d) {
58*f4a2713aSLionel Sambuc   d.template Derived1T<T>::Foo();
59*f4a2713aSLionel Sambuc   d.template Derived2T<T>::Member = 17;
60*f4a2713aSLionel Sambuc   d.Inner(); // expected-note{{in instantiation}}
61*f4a2713aSLionel Sambuc }
62*f4a2713aSLionel Sambuc 
63*f4a2713aSLionel Sambuc template void Test(DerivedT<int>);
64