|
| 1 | +// RUN: %clang_cc1 -std=c++23 %s -verify |
| 2 | + |
| 3 | +namespace FoundNothing { |
| 4 | + template<typename T> |
| 5 | + void f0(T &t) { |
| 6 | + t.x<0; |
| 7 | + t.x<0>; // expected-error {{expected expression}} |
| 8 | + t.x<0>1; |
| 9 | + } |
| 10 | + |
| 11 | + template<typename T> |
| 12 | + struct A { |
| 13 | + void f1() { |
| 14 | + this->x<0; // expected-error {{no member named 'x' in 'A<T>'}} |
| 15 | + this->x<0>; // expected-error {{expected expression}} |
| 16 | + // expected-error@-1 {{no member named 'x' in 'A<T>'}} |
| 17 | + this->x<0>1; // expected-error {{no member named 'x' in 'A<T>'}} |
| 18 | + } |
| 19 | + }; |
| 20 | +} // namespace FoundNothing |
| 21 | + |
| 22 | +namespace FoundSingleNonTemplate { |
| 23 | + void f0(); |
| 24 | + |
| 25 | + struct A0; |
| 26 | + |
| 27 | + template<typename T> |
| 28 | + void g0(T &t) { |
| 29 | + t.f0<0; |
| 30 | + t.f0<0>; // expected-error {{expected expression}} |
| 31 | + t.f0<0> 1; |
| 32 | + |
| 33 | + t.A0<0; |
| 34 | + t.A0<0>; // expected-error {{expected expression}} |
| 35 | + t.A0<0>1; |
| 36 | + } |
| 37 | + |
| 38 | + template<typename T> |
| 39 | + struct B { |
| 40 | + void f1(); |
| 41 | + |
| 42 | + struct A1; // expected-note 3{{member 'A1' declared here}} |
| 43 | + |
| 44 | + void g1() { |
| 45 | + this->f0<0; // expected-error {{no member named 'f0' in 'B<T>'}} |
| 46 | + this->f0<0>; // expected-error {{expected expression}} |
| 47 | + // expected-error@-1 {{no member named 'f0' in 'B<T>'}} |
| 48 | + this->f0<0>1; // expected-error {{no member named 'f0' in 'B<T>'}} |
| 49 | + |
| 50 | + this->A0<0; // expected-error {{no member named 'A0' in 'B<T>'}} |
| 51 | + this->A0<0>; // expected-error {{expected expression}} |
| 52 | + // expected-error@-1 {{no member named 'A0' in 'B<T>'}} |
| 53 | + this->A0<0>1; // expected-error {{no member named 'A0' in 'B<T>'}} |
| 54 | + |
| 55 | + this->f1<0; // expected-error {{reference to non-static member function must be called}} |
| 56 | + this->f1<0>; // expected-error {{expected expression}} |
| 57 | + // expected-error@-1 {{reference to non-static member function must be called}} |
| 58 | + this->f1<0>1; // expected-error {{reference to non-static member function must be called}} |
| 59 | + |
| 60 | + this->A1<0; // expected-error {{cannot refer to type member 'A1' in 'B<T>' with '->'}} |
| 61 | + this->A1<0>; // expected-error {{expected expression}} |
| 62 | + // expected-error@-1 {{cannot refer to type member 'A1' in 'B<T>' with '->'}} |
| 63 | + this->A1<0>1; // expected-error {{cannot refer to type member 'A1' in 'B<T>' with '->'}} |
| 64 | + } |
| 65 | + }; |
| 66 | +} // namespace FoundSingleNonTemplate |
| 67 | + |
| 68 | +namespace FoundSingleTemplate { |
| 69 | + template<int I> |
| 70 | + void f0(); |
| 71 | + |
| 72 | + template<int I> |
| 73 | + struct A0; |
| 74 | + |
| 75 | + template<typename T> |
| 76 | + void g0(T &t) { |
| 77 | + t.f0<0; |
| 78 | + t.f0<0>; // expected-error {{expected expression}} |
| 79 | + t.f0<0>1; |
| 80 | + |
| 81 | + t.A0<0; |
| 82 | + t.A0<0>; // expected-error {{expected expression}} |
| 83 | + t.A0<0>1; |
| 84 | + } |
| 85 | + |
| 86 | + template<typename T> |
| 87 | + struct B { |
| 88 | + template<int I> |
| 89 | + void f1(); // expected-note 2{{possible target for call}} |
| 90 | + |
| 91 | + template<int I> |
| 92 | + struct A1; // expected-note 2{{member 'A1' declared here}} |
| 93 | + |
| 94 | + void g1() { |
| 95 | + this->f0<0; // expected-error {{expected '>'}} |
| 96 | + // expected-note@-1 {{to match this '<'}} |
| 97 | + // expected-error@-2 {{expected unqualified-id}} |
| 98 | + this->f0<0>; // expected-error {{no member named 'f0' in 'B<T>'}} |
| 99 | + this->f0<0>1; // expected-error {{no member named 'f0' in 'B<T>'}} |
| 100 | + // expected-error@-1 {{expected ';' after expression}} |
| 101 | + |
| 102 | + this->A0<0; // expected-error {{expected '>'}} |
| 103 | + // expected-note@-1 {{to match this '<'}} |
| 104 | + // expected-error@-2 {{expected unqualified-id}} |
| 105 | + this->A0<0>; // expected-error {{no member named 'A0' in 'B<T>'}} |
| 106 | + this->A0<0>1; // expected-error {{no member named 'A0' in 'B<T>'}} |
| 107 | + // expected-error@-1 {{expected ';' after expression}} |
| 108 | + |
| 109 | + |
| 110 | + this->f1<0; // expected-error {{expected '>'}} |
| 111 | + // expected-note@-1 {{to match this '<'}} |
| 112 | + // expected-error@-2 {{expected unqualified-id}} |
| 113 | + this->f1<0>; // expected-error {{reference to non-static member function must be called}} |
| 114 | + this->f1<0>1; // expected-error {{reference to non-static member function must be called}} |
| 115 | + // expected-error@-1 {{expected ';' after expression}} |
| 116 | + |
| 117 | + this->A1<0; // expected-error {{expected '>'}} |
| 118 | + // expected-note@-1 {{to match this '<'}} |
| 119 | + // expected-error@-2 {{expected unqualified-id}} |
| 120 | + this->A1<0>; // expected-error {{cannot refer to member 'A1' in 'B<T>' with '->'}} |
| 121 | + this->A1<0>1; // expected-error {{cannot refer to member 'A1' in 'B<T>' with '->'}} |
| 122 | + // expected-error@-1 {{expected ';' after expression}} |
| 123 | + } |
| 124 | + }; |
| 125 | +} // namespace FoundSingleTemplate |
| 126 | + |
| 127 | +namespace FoundAmbiguousNonTemplate { |
| 128 | + inline namespace N { |
| 129 | + int f0; |
| 130 | + |
| 131 | + struct A0; |
| 132 | + } // namespace N |
| 133 | + |
| 134 | + void f0(); |
| 135 | + |
| 136 | + struct A0; |
| 137 | + |
| 138 | + template<typename T> |
| 139 | + void g0(T &t) { |
| 140 | + t.f0<0; |
| 141 | + t.f0<0>; // expected-error {{expected expression}} |
| 142 | + t.f0<0>1; |
| 143 | + |
| 144 | + t.A0<0; |
| 145 | + t.A0<0>; // expected-error {{expected expression}} |
| 146 | + t.A0<0>1; |
| 147 | + } |
| 148 | + |
| 149 | + template<typename T> |
| 150 | + struct B { |
| 151 | + void f1(); |
| 152 | + |
| 153 | + struct A1; // expected-note 3{{member 'A1' declared here}} |
| 154 | + |
| 155 | + void g1() { |
| 156 | + this->f0<0; // expected-error {{no member named 'f0' in 'B<T>'}} |
| 157 | + this->f0<0>; // expected-error {{expected expression}} |
| 158 | + // expected-error@-1 {{no member named 'f0' in 'B<T>'}} |
| 159 | + this->f0<0>1; // expected-error {{no member named 'f0' in 'B<T>'}} |
| 160 | + |
| 161 | + this->A0<0; // expected-error {{no member named 'A0' in 'B<T>'}} |
| 162 | + this->A0<0>; // expected-error {{expected expression}} |
| 163 | + // expected-error@-1 {{no member named 'A0' in 'B<T>'}} |
| 164 | + this->A0<0>1; // expected-error {{no member named 'A0' in 'B<T>'}} |
| 165 | + |
| 166 | + this->f1<0; // expected-error {{reference to non-static member function must be called}} |
| 167 | + this->f1<0>; // expected-error {{expected expression}} |
| 168 | + // expected-error@-1 {{reference to non-static member function must be called}} |
| 169 | + this->f1<0>1; // expected-error {{reference to non-static member function must be called}} |
| 170 | + |
| 171 | + this->A1<0; // expected-error {{cannot refer to type member 'A1' in 'B<T>' with '->'}} |
| 172 | + this->A1<0>; // expected-error {{expected expression}} |
| 173 | + // expected-error@-1 {{cannot refer to type member 'A1' in 'B<T>' with '->'}} |
| 174 | + this->A1<0>1; // expected-error {{cannot refer to type member 'A1' in 'B<T>' with '->'}} |
| 175 | + } |
| 176 | + }; |
| 177 | +} // namespace FoundAmbiguousNonTemplates |
| 178 | + |
| 179 | +namespace FoundAmbiguousTemplate { |
| 180 | + inline namespace N { |
| 181 | + template<int I> |
| 182 | + int f0; // expected-note 3{{candidate found by name lookup is 'FoundAmbiguousTemplate::N::f0'}} |
| 183 | + |
| 184 | + template<int I> |
| 185 | + struct A0; // expected-note 3{{candidate found by name lookup is 'FoundAmbiguousTemplate::N::A0'}} |
| 186 | + } // namespace N |
| 187 | + |
| 188 | + template<int I> |
| 189 | + void f0(); // expected-note 3{{candidate found by name lookup is 'FoundAmbiguousTemplate::f0'}} |
| 190 | + |
| 191 | + template<int I> |
| 192 | + struct A0; // expected-note 3{{candidate found by name lookup is 'FoundAmbiguousTemplate::A0'}} |
| 193 | + |
| 194 | + template<typename T> |
| 195 | + void g0(T &t) { |
| 196 | + t.f0<0; |
| 197 | + t.f0<0>; // expected-error {{expected expression}} |
| 198 | + t.f0<0>1; |
| 199 | + |
| 200 | + t.A0<0; |
| 201 | + t.A0<0>; // expected-error {{expected expression}} |
| 202 | + t.A0<0>1; |
| 203 | + } |
| 204 | + |
| 205 | + template<typename T> |
| 206 | + struct B { |
| 207 | + template<int I> |
| 208 | + void f1(); // expected-note 2{{possible target for call}} |
| 209 | + |
| 210 | + template<int I> |
| 211 | + struct A1; // expected-note 2{{member 'A1' declared here}} |
| 212 | + |
| 213 | + void g1() { |
| 214 | + this->f0<0; // expected-error {{expected '>'}} |
| 215 | + // expected-note@-1 {{to match this '<'}} |
| 216 | + // expected-error@-2 {{expected unqualified-id}} |
| 217 | + // expected-error@-3 {{reference to 'f0' is ambiguous}} |
| 218 | + this->f0<0>; // expected-error {{no member named 'f0' in 'B<T>'}} |
| 219 | + // expected-error@-1 {{reference to 'f0' is ambiguous}} |
| 220 | + this->f0<0>1; // expected-error {{no member named 'f0' in 'B<T>'}} |
| 221 | + // expected-error@-1 {{expected ';' after expression}} |
| 222 | + // expected-error@-2 {{reference to 'f0' is ambiguous}} |
| 223 | + |
| 224 | + this->A0<0; // expected-error {{expected '>'}} |
| 225 | + // expected-note@-1 {{to match this '<'}} |
| 226 | + // expected-error@-2 {{expected unqualified-id}} |
| 227 | + // expected-error@-3 {{reference to 'A0' is ambiguous}} |
| 228 | + this->A0<0>; // expected-error {{no member named 'A0' in 'B<T>'}} |
| 229 | + // expected-error@-1 {{reference to 'A0' is ambiguous}} |
| 230 | + this->A0<0>1; // expected-error {{no member named 'A0' in 'B<T>'}} |
| 231 | + // expected-error@-1 {{expected ';' after expression}} |
| 232 | + // expected-error@-2 {{reference to 'A0' is ambiguous}} |
| 233 | + |
| 234 | + |
| 235 | + this->f1<0; // expected-error {{expected '>'}} |
| 236 | + // expected-note@-1 {{to match this '<'}} |
| 237 | + // expected-error@-2 {{expected unqualified-id}} |
| 238 | + this->f1<0>; // expected-error {{reference to non-static member function must be called}} |
| 239 | + this->f1<0>1; // expected-error {{reference to non-static member function must be called}} |
| 240 | + // expected-error@-1 {{expected ';' after expression}} |
| 241 | + |
| 242 | + this->A1<0; // expected-error {{expected '>'}} |
| 243 | + // expected-note@-1 {{to match this '<'}} |
| 244 | + // expected-error@-2 {{expected unqualified-id}} |
| 245 | + this->A1<0>; // expected-error {{cannot refer to member 'A1' in 'B<T>' with '->'}} |
| 246 | + this->A1<0>1; // expected-error {{cannot refer to member 'A1' in 'B<T>' with '->'}} |
| 247 | + // expected-error@-1 {{expected ';' after expression}} |
| 248 | + } |
| 249 | + }; |
| 250 | +} // namespace FoundAmbiguousTemplate |
0 commit comments