Skip to content

Commit a4a51f2

Browse files
committed
Add tests for move.
Note that if there is an invalid move constructor, overload resolution will try to pick a copy constructor instead.
1 parent 885bdd5 commit a4a51f2

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

clang/test/SemaCXX/cxx2b-deducing-this.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -608,11 +608,21 @@ S2& S2::operator=(this int&& self, const S2&) = default;
608608
S2& S2::operator=(this int&& self, S2&&) = default;
609609
// 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'}}
610610

611+
struct Move {
612+
Move& operator=(this int&, Move&&) = default;
613+
// expected-warning@-1 {{explicitly defaulted move assignment operator is implicitly deleted}}
614+
// expected-note@-2 {{function is implicitly deleted because its declared type does not match the type of an implicit move assignment operator}}
615+
// expected-note@-3 {{copy assignment operator is implicitly deleted because 'Move' has a user-declared move assignment operator}}
616+
};
617+
611618
void test() {
612619
S s;
613620
s = s; // expected-error {{object of type 'S' cannot be assigned because its copy assignment operator is implicitly deleted}}
614621
S2 s2;
615622
s2 = s2;
623+
624+
Move m;
625+
m = Move{}; // expected-error {{object of type 'Move' cannot be assigned because its copy assignment operator is implicitly deleted}}
616626
}
617627

618628
}

0 commit comments

Comments
 (0)