================ @@ -585,3 +585,34 @@ class Server : public Thing { S name_; }; } + +namespace GH69233 { +struct Base {}; +struct S : Base { + int j; + S& operator=(this Base& self, const S&) = default; + // expected-warning@-1 {{explicitly defaulted copy assignment operator is implicitly deleted}} + // expected-note@-2 {{function is implicitly deleted because its declared type does not match the type of an implicit copy assignment operator}} + // expected-note@-3 {{explicitly defaulted function was implicitly deleted here}} +}; + +struct S2 { + S2& operator=(this int&& self, const S2&); + S2& operator=(this int&& self, S2&&); + operator int(); +}; + +S2& S2::operator=(this int&& self, const S2&) = default; +// expected-error@-1 {{the type of the explicit object parameter of an explicitly-defaulted copy assignment operator should match the type of the class 'S2'}} + +S2& S2::operator=(this int&& self, S2&&) = default; +// expected-error@-1 {{the type of the explicit object parameter of an explicitly-defaulted move assignment operator should match the type of the class 'S2'}} + +void test() { + S s; + s = s; // expected-error {{object of type 'S' cannot be assigned because its copy assignment operator is implicitly deleted}} ---------------- shafik wrote:
Can we get an example where move assignment fails as well. https://github.com/llvm/llvm-project/pull/70176 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits