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