Fixed #7987 (FP copyCtorAndEqOperator - class with a move constructor and move assignment operator)
This commit is contained in:
parent
5ed2dbd5ef
commit
91839c2534
|
@ -2405,6 +2405,7 @@ void CheckClass::checkCopyCtorAndEqOperator()
|
|||
continue;
|
||||
|
||||
CtorType copyCtors = CtorType::NO;
|
||||
bool moveCtor = false;
|
||||
CtorType assignmentOperators = CtorType::NO;
|
||||
|
||||
std::list<Function>::const_iterator func;
|
||||
|
@ -2418,7 +2419,14 @@ void CheckClass::checkCopyCtorAndEqOperator()
|
|||
assignmentOperators = func->hasBody() ? CtorType::WITH_BODY : CtorType::WITHOUT_BODY;
|
||||
}
|
||||
}
|
||||
if (func->type == Function::eMoveConstructor) {
|
||||
moveCtor = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (moveCtor)
|
||||
continue;
|
||||
|
||||
if ((copyCtors == CtorType::WITH_BODY && assignmentOperators == CtorType::NO) ||
|
||||
(copyCtors == CtorType::NO && assignmentOperators == CtorType::WITH_BODY))
|
||||
|
|
|
@ -276,6 +276,17 @@ private:
|
|||
" static int i;\n"
|
||||
"};");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// #7987 - Don't show warning when there is a move constructor
|
||||
checkCopyCtorAndEqOperator("struct S {\n"
|
||||
" std::string test;\n"
|
||||
" S(S&& s) : test(std::move(s.test)) { }\n"
|
||||
" S& operator = (S &&s) {\n"
|
||||
" test = std::move(s.test);\n"
|
||||
" return *this;\n"
|
||||
" }\n"
|
||||
"};\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void checkExplicitConstructors(const char code[]) {
|
||||
|
|
Loading…
Reference in New Issue