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