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