1 // RUN: %clang_cc1 -fsyntax-only -verify %s
2 struct A {
3   int a;  // expected-note 4{{member found by ambiguous name lookup}}
4   static int b;
5   static int c; // expected-note 2{{member found by ambiguous name lookup}}
6 
7   enum E { enumerator };
8 
9   typedef int type;
10 
11   static void f(int);
12   void f(float); // expected-note 2{{member found by ambiguous name lookup}}
13 
14   static void static_f(int);
15   static void static_f(double);
16 };
17 
18 struct B : A {
19   int d; // expected-note 2{{member found by ambiguous name lookup}}
20 
21   enum E2 { enumerator2 };
22 
23   enum E3 { enumerator3 }; // expected-note 2{{member found by ambiguous name lookup}}
24 };
25 
26 struct C : A {
27   int c; // expected-note 2{{member found by ambiguous name lookup}}
28   int d; // expected-note 2{{member found by ambiguous name lookup}}
29 
30   enum E3 { enumerator3_2 }; // expected-note 2{{member found by ambiguous name lookup}}
31 };
32 
33 struct D : B, C {
34   void test_lookup();
35 };
36 
test_lookup(D d)37 void test_lookup(D d) {
38   d.a; // expected-error{{non-static member 'a' found in multiple base-class subobjects of type 'A':}}
39   (void)d.b; // okay
40   d.c; // expected-error{{member 'c' found in multiple base classes of different types}}
41   d.d; // expected-error{{member 'd' found in multiple base classes of different types}}
42   d.f(0); // expected-error{{non-static member 'f' found in multiple base-class subobjects of type 'A':}}
43   d.static_f(0); // okay
44 
45   D::E e = D::enumerator; // okay
46   D::type t = 0; // okay
47 
48   D::E2 e2 = D::enumerator2; // okay
49 
50   D::E3 e3; // expected-error{{multiple base classes}}
51 }
52 
test_lookup()53 void D::test_lookup() {
54   a; // expected-error{{non-static member 'a' found in multiple base-class subobjects of type 'A':}}
55   (void)b; // okay
56   c; // expected-error{{member 'c' found in multiple base classes of different types}}
57   d; // expected-error{{member 'd' found in multiple base classes of different types}}
58   f(0); // expected-error{{non-static member 'f' found in multiple base-class subobjects of type 'A':}}
59   static_f(0); // okay
60 
61   E e = enumerator; // okay
62   type t = 0; // okay
63 
64   E2 e2 = enumerator2; // okay
65 
66   E3 e3; // expected-error{{member 'E3' found in multiple base classes of different types}}
67 }
68 
69 struct B2 : virtual A {
70   int d; // expected-note 2{{member found by ambiguous name lookup}}
71 
72   enum E2 { enumerator2 };
73 
74   enum E3 { enumerator3 }; // expected-note 2 {{member found by ambiguous name lookup}}
75 };
76 
77 struct C2 : virtual A {
78   int c;
79   int d; // expected-note 2{{member found by ambiguous name lookup}}
80 
81   enum E3 { enumerator3_2 }; // expected-note 2{{member found by ambiguous name lookup}}
82 };
83 
84 struct D2 : B2, C2 {
85   void test_virtual_lookup();
86 };
87 
88 struct F : A { };
89 struct G : F, D2 {
90   void test_virtual_lookup();
91 };
92 
test_virtual_lookup(D2 d2,G g)93 void test_virtual_lookup(D2 d2, G g) {
94   (void)d2.a;
95   (void)d2.b;
96   (void)d2.c; // okay
97   d2.d; // expected-error{{member 'd' found in multiple base classes of different types}}
98   d2.f(0); // okay
99   d2.static_f(0); // okay
100 
101   D2::E e = D2::enumerator; // okay
102   D2::type t = 0; // okay
103 
104   D2::E2 e2 = D2::enumerator2; // okay
105 
106   D2::E3 e3; // expected-error{{member 'E3' found in multiple base classes of different types}}
107 
108   g.a; // expected-error{{non-static member 'a' found in multiple base-class subobjects of type 'A':}}
109   g.static_f(0); // okay
110 }
111 
test_virtual_lookup()112 void D2::test_virtual_lookup() {
113   (void)a;
114   (void)b;
115   (void)c; // okay
116   d; // expected-error{{member 'd' found in multiple base classes of different types}}
117   f(0); // okay
118   static_f(0); // okay
119 
120   E e = enumerator; // okay
121   type t = 0; // okay
122 
123   E2 e2 = enumerator2; // okay
124 
125   E3 e3; // expected-error{{member 'E3' found in multiple base classes of different types}}
126 }
127 
test_virtual_lookup()128 void G::test_virtual_lookup() {
129   a; // expected-error{{non-static member 'a' found in multiple base-class subobjects of type 'A':}}
130   static_f(0); // okay
131 }
132 
133 
134 struct HasMemberType1 {
135   struct type { }; // expected-note{{member found by ambiguous name lookup}}
136 };
137 
138 struct HasMemberType2 {
139   struct type { }; // expected-note{{member found by ambiguous name lookup}}
140 };
141 
142 struct HasAnotherMemberType : HasMemberType1, HasMemberType2 {
143   struct type { };
144 };
145 
146 struct UsesAmbigMemberType : HasMemberType1, HasMemberType2 {
147   type t; // expected-error{{member 'type' found in multiple base classes of different types}}
148 };
149 
150 struct X0 {
151   struct Inner {
152     static const int m;
153   };
154 
155   static const int n = 17;
156 };
157 
158 const int X0::Inner::m = n;
159