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