@@ -1290,3 +1290,60 @@ void f() {
1290
1290
1291
1291
1292
1292
}
1293
+
1294
+ namespace GH147121 {
1295
+ struct X {};
1296
+ struct S1 {
1297
+ bool operator ==(this auto &&, const X &); // #S1-cand
1298
+ };
1299
+ struct S2 {
1300
+ bool operator ==(this X, const auto &&); // #S2-cand
1301
+ };
1302
+
1303
+ struct S3 {
1304
+ S3& operator ++(this X); // #S3-inc-cand
1305
+ S3& operator ++(this int ); // #S3-inc-cand
1306
+ int operator [](this X); // #S3-sub-cand
1307
+ int operator [](this int ); // #S3-sub-cand2
1308
+ void f (this X); // #S3-f-cand
1309
+ void f (this int ); // #S3-f-cand2
1310
+ };
1311
+
1312
+ int main () {
1313
+ S1{} == S1{};
1314
+ // expected-error@-1 {{invalid operands to binary expression ('S1' and 'S1')}}
1315
+ // expected-note@#S1-cand {{candidate function template not viable}}
1316
+ // expected-note@#S1-cand {{candidate function (with reversed parameter order) template not viable}}
1317
+
1318
+
1319
+ S1{} != S1{};
1320
+ // expected-error@-1 {{invalid operands to binary expression ('S1' and 'S1')}}
1321
+ // expected-note@#S1-cand {{candidate function template not viable}}
1322
+ // expected-note@#S1-cand {{candidate function (with reversed parameter order) template not viable}}
1323
+
1324
+
1325
+ S2{} == S2{};
1326
+ // expected-error@-1 {{invalid operands to binary expression ('S2' and 'S2')}}
1327
+ // expected-note@#S2-cand {{candidate function template not viable}}
1328
+ // expected-note@#S2-cand {{candidate function (with reversed parameter order) template not viable}}
1329
+
1330
+
1331
+ S2{} != S2{};
1332
+ // expected-error@-1 {{invalid operands to binary expression ('S2' and 'S2')}}
1333
+ // expected-note@#S2-cand {{candidate function template not viable}}
1334
+ // expected-note@#S2-cand {{candidate function (with reversed parameter order) template not viable}}
1335
+
1336
+ S3 s3;
1337
+ ++s3;
1338
+ // expected-error@-1{{cannot increment value of type 'S3'}}
1339
+ s3[];
1340
+ // expected-error@-1{{no viable overloaded operator[] for type 'S3'}}
1341
+ // expected-note@#S3-sub-cand {{candidate function not viable: no known conversion from 'S3' to 'X' for object argument}}
1342
+ // expected-note@#S3-sub-cand2 {{candidate function not viable: no known conversion from 'S3' to 'int' for object argument}}
1343
+
1344
+ s3.f ();
1345
+ // expected-error@-1{{no matching member function for call to 'f'}}
1346
+ // expected-note@#S3-f-cand {{candidate function not viable: no known conversion from 'S3' to 'X' for object argument}}
1347
+ // expected-note@#S3-f-cand2 {{candidate function not viable: no known conversion from 'S3' to 'int' for object argument}}
1348
+ }
1349
+ }
0 commit comments