2009-12-16 04:14:24 +08:00
|
|
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
|
2009-01-17 01:06:33 +08:00
|
|
|
struct A {
|
2009-04-02 05:51:26 +08:00
|
|
|
int a; // expected-note 4{{member found by ambiguous name lookup}}
|
2009-01-17 01:06:33 +08:00
|
|
|
static int b;
|
2010-03-03 12:38:46 +08:00
|
|
|
static int c; // expected-note 2{{member found by ambiguous name lookup}}
|
2009-01-17 01:06:33 +08:00
|
|
|
|
|
|
|
enum E { enumerator };
|
|
|
|
|
|
|
|
typedef int type;
|
|
|
|
|
|
|
|
static void f(int);
|
2009-04-02 05:51:26 +08:00
|
|
|
void f(float); // expected-note 2{{member found by ambiguous name lookup}}
|
2009-01-17 01:06:33 +08:00
|
|
|
|
|
|
|
static void static_f(int);
|
|
|
|
static void static_f(double);
|
|
|
|
};
|
|
|
|
|
|
|
|
struct B : A {
|
2009-04-02 05:51:26 +08:00
|
|
|
int d; // expected-note 2{{member found by ambiguous name lookup}}
|
2009-01-17 01:06:33 +08:00
|
|
|
|
|
|
|
enum E2 { enumerator2 };
|
|
|
|
|
2020-11-26 09:00:23 +08:00
|
|
|
enum E3 { enumerator3 }; // expected-note 2{{member type 'B::E3' found by ambiguous name lookup}}
|
2009-01-17 01:06:33 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct C : A {
|
2009-04-02 05:51:26 +08:00
|
|
|
int c; // expected-note 2{{member found by ambiguous name lookup}}
|
|
|
|
int d; // expected-note 2{{member found by ambiguous name lookup}}
|
2009-01-17 01:06:33 +08:00
|
|
|
|
2020-11-26 09:00:23 +08:00
|
|
|
enum E3 { enumerator3_2 }; // expected-note 2{{member type 'C::E3' found by ambiguous name lookup}}
|
2009-01-17 01:06:33 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct D : B, C {
|
|
|
|
void test_lookup();
|
|
|
|
};
|
|
|
|
|
|
|
|
void test_lookup(D d) {
|
2010-03-10 19:27:22 +08:00
|
|
|
d.a; // expected-error{{non-static member 'a' found in multiple base-class subobjects of type 'A':}}
|
2009-01-17 01:06:33 +08:00
|
|
|
(void)d.b; // okay
|
|
|
|
d.c; // expected-error{{member 'c' found in multiple base classes of different types}}
|
|
|
|
d.d; // expected-error{{member 'd' found in multiple base classes of different types}}
|
2010-03-10 19:27:22 +08:00
|
|
|
d.f(0); // expected-error{{non-static member 'f' found in multiple base-class subobjects of type 'A':}}
|
2009-01-17 01:06:33 +08:00
|
|
|
d.static_f(0); // okay
|
|
|
|
|
|
|
|
D::E e = D::enumerator; // okay
|
|
|
|
D::type t = 0; // okay
|
|
|
|
|
|
|
|
D::E2 e2 = D::enumerator2; // okay
|
|
|
|
|
2009-04-02 05:51:26 +08:00
|
|
|
D::E3 e3; // expected-error{{multiple base classes}}
|
2009-01-17 01:06:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void D::test_lookup() {
|
2010-03-10 19:27:22 +08:00
|
|
|
a; // expected-error{{non-static member 'a' found in multiple base-class subobjects of type 'A':}}
|
2009-01-17 01:06:33 +08:00
|
|
|
(void)b; // okay
|
|
|
|
c; // expected-error{{member 'c' found in multiple base classes of different types}}
|
|
|
|
d; // expected-error{{member 'd' found in multiple base classes of different types}}
|
2010-03-10 19:27:22 +08:00
|
|
|
f(0); // expected-error{{non-static member 'f' found in multiple base-class subobjects of type 'A':}}
|
2009-01-17 01:06:33 +08:00
|
|
|
static_f(0); // okay
|
|
|
|
|
2009-01-17 03:38:23 +08:00
|
|
|
E e = enumerator; // okay
|
2009-01-17 01:06:33 +08:00
|
|
|
type t = 0; // okay
|
|
|
|
|
2009-01-17 03:38:23 +08:00
|
|
|
E2 e2 = enumerator2; // okay
|
2009-01-17 01:06:33 +08:00
|
|
|
|
|
|
|
E3 e3; // expected-error{{member 'E3' found in multiple base classes of different types}}
|
|
|
|
}
|
|
|
|
|
|
|
|
struct B2 : virtual A {
|
2009-04-02 05:51:26 +08:00
|
|
|
int d; // expected-note 2{{member found by ambiguous name lookup}}
|
2009-01-17 01:06:33 +08:00
|
|
|
|
|
|
|
enum E2 { enumerator2 };
|
|
|
|
|
2020-11-26 09:00:23 +08:00
|
|
|
enum E3 { enumerator3 }; // expected-note 2 {{member type 'B2::E3' found by ambiguous name lookup}}
|
2009-01-17 01:06:33 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct C2 : virtual A {
|
2010-03-03 12:38:46 +08:00
|
|
|
int c;
|
2009-04-02 05:51:26 +08:00
|
|
|
int d; // expected-note 2{{member found by ambiguous name lookup}}
|
2009-01-17 01:06:33 +08:00
|
|
|
|
2020-11-26 09:00:23 +08:00
|
|
|
enum E3 { enumerator3_2 }; // expected-note 2{{member type 'C2::E3' found by ambiguous name lookup}}
|
2009-01-17 01:06:33 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct D2 : B2, C2 {
|
|
|
|
void test_virtual_lookup();
|
|
|
|
};
|
|
|
|
|
|
|
|
struct F : A { };
|
|
|
|
struct G : F, D2 {
|
|
|
|
void test_virtual_lookup();
|
|
|
|
};
|
|
|
|
|
|
|
|
void test_virtual_lookup(D2 d2, G g) {
|
|
|
|
(void)d2.a;
|
|
|
|
(void)d2.b;
|
2010-03-03 12:38:46 +08:00
|
|
|
(void)d2.c; // okay
|
2009-01-17 01:06:33 +08:00
|
|
|
d2.d; // expected-error{{member 'd' found in multiple base classes of different types}}
|
|
|
|
d2.f(0); // okay
|
|
|
|
d2.static_f(0); // okay
|
|
|
|
|
|
|
|
D2::E e = D2::enumerator; // okay
|
|
|
|
D2::type t = 0; // okay
|
|
|
|
|
|
|
|
D2::E2 e2 = D2::enumerator2; // okay
|
|
|
|
|
|
|
|
D2::E3 e3; // expected-error{{member 'E3' found in multiple base classes of different types}}
|
|
|
|
|
2010-03-10 19:27:22 +08:00
|
|
|
g.a; // expected-error{{non-static member 'a' found in multiple base-class subobjects of type 'A':}}
|
2009-01-17 01:06:33 +08:00
|
|
|
g.static_f(0); // okay
|
|
|
|
}
|
|
|
|
|
|
|
|
void D2::test_virtual_lookup() {
|
|
|
|
(void)a;
|
|
|
|
(void)b;
|
2010-03-03 12:38:46 +08:00
|
|
|
(void)c; // okay
|
2009-01-17 01:06:33 +08:00
|
|
|
d; // expected-error{{member 'd' found in multiple base classes of different types}}
|
|
|
|
f(0); // okay
|
|
|
|
static_f(0); // okay
|
|
|
|
|
|
|
|
E e = enumerator; // okay
|
|
|
|
type t = 0; // okay
|
|
|
|
|
|
|
|
E2 e2 = enumerator2; // okay
|
|
|
|
|
|
|
|
E3 e3; // expected-error{{member 'E3' found in multiple base classes of different types}}
|
|
|
|
}
|
|
|
|
|
|
|
|
void G::test_virtual_lookup() {
|
2010-03-10 19:27:22 +08:00
|
|
|
a; // expected-error{{non-static member 'a' found in multiple base-class subobjects of type 'A':}}
|
2009-01-17 01:06:33 +08:00
|
|
|
static_f(0); // okay
|
|
|
|
}
|
2009-02-04 03:21:40 +08:00
|
|
|
|
|
|
|
|
|
|
|
struct HasMemberType1 {
|
2020-11-26 09:00:23 +08:00
|
|
|
struct type { }; // expected-note{{member type 'HasMemberType1::type' found by ambiguous name lookup}}
|
2009-02-04 03:21:40 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct HasMemberType2 {
|
2020-11-26 09:00:23 +08:00
|
|
|
struct type { }; // expected-note{{member type 'HasMemberType2::type' found by ambiguous name lookup}}
|
2009-02-04 03:21:40 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct HasAnotherMemberType : HasMemberType1, HasMemberType2 {
|
2009-02-04 03:26:08 +08:00
|
|
|
struct type { };
|
2009-02-04 03:21:40 +08:00
|
|
|
};
|
2009-02-05 01:00:24 +08:00
|
|
|
|
|
|
|
struct UsesAmbigMemberType : HasMemberType1, HasMemberType2 {
|
2009-04-02 05:51:26 +08:00
|
|
|
type t; // expected-error{{member 'type' found in multiple base classes of different types}}
|
2009-02-05 01:00:24 +08:00
|
|
|
};
|
2009-09-11 00:57:35 +08:00
|
|
|
|
|
|
|
struct X0 {
|
|
|
|
struct Inner {
|
|
|
|
static const int m;
|
|
|
|
};
|
|
|
|
|
|
|
|
static const int n = 17;
|
|
|
|
};
|
|
|
|
|
|
|
|
const int X0::Inner::m = n;
|