[docs] Add LICENSE.txt to the root of the mono-repo
[llvm-project.git] / clang / test / SemaCXX / member-name-lookup.cpp
blobcfd00b35421e7f5d9ccd0cdf4fbc7c736e4cdc4c
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}}
7 enum E { enumerator };
9 typedef int type;
11 static void f(int);
12 void f(float); // expected-note 2{{member found by ambiguous name lookup}}
14 static void static_f(int);
15 static void static_f(double);
18 struct B : A {
19 int d; // expected-note 2{{member found by ambiguous name lookup}}
21 enum E2 { enumerator2 };
23 enum E3 { enumerator3 }; // expected-note 2{{member type 'B::E3' found by ambiguous name lookup}}
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}}
30 enum E3 { enumerator3_2 }; // expected-note 2{{member type 'C::E3' found by ambiguous name lookup}}
33 struct D : B, C {
34 void test_lookup();
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
45 D::E e = D::enumerator; // okay
46 D::type t = 0; // okay
48 D::E2 e2 = D::enumerator2; // okay
50 D::E3 e3; // expected-error{{multiple base classes}}
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
61 E e = enumerator; // okay
62 type t = 0; // okay
64 E2 e2 = enumerator2; // okay
66 E3 e3; // expected-error{{member 'E3' found in multiple base classes of different types}}
69 struct B2 : virtual A {
70 int d; // expected-note 2{{member found by ambiguous name lookup}}
72 enum E2 { enumerator2 };
74 enum E3 { enumerator3 }; // expected-note 2 {{member type 'B2::E3' found by ambiguous name lookup}}
77 struct C2 : virtual A {
78 int c;
79 int d; // expected-note 2{{member found by ambiguous name lookup}}
81 enum E3 { enumerator3_2 }; // expected-note 2{{member type 'C2::E3' found by ambiguous name lookup}}
84 struct D2 : B2, C2 {
85 void test_virtual_lookup();
88 struct F : A { };
89 struct G : F, D2 {
90 void test_virtual_lookup();
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
101 D2::E e = D2::enumerator; // okay
102 D2::type t = 0; // okay
104 D2::E2 e2 = D2::enumerator2; // okay
106 D2::E3 e3; // expected-error{{member 'E3' found in multiple base classes of different types}}
108 g.a; // expected-error{{non-static member 'a' found in multiple base-class subobjects of type 'A':}}
109 g.static_f(0); // okay
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
120 E e = enumerator; // okay
121 type t = 0; // okay
123 E2 e2 = enumerator2; // okay
125 E3 e3; // expected-error{{member 'E3' found in multiple base classes of different types}}
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
134 struct HasMemberType1 {
135 struct type { }; // expected-note{{member type 'HasMemberType1::type' found by ambiguous name lookup}}
138 struct HasMemberType2 {
139 struct type { }; // expected-note{{member type 'HasMemberType2::type' found by ambiguous name lookup}}
142 struct HasAnotherMemberType : HasMemberType1, HasMemberType2 {
143 struct type { };
146 struct UsesAmbigMemberType : HasMemberType1, HasMemberType2 {
147 type t; // expected-error{{member 'type' found in multiple base classes of different types}}
150 struct X0 {
151 struct Inner {
152 static const int m;
155 static const int n = 17;
158 const int X0::Inner::m = n;