Fix false positive with ignoredReturnValue with std::move (#1809)
This commit is contained in:
parent
b1ca7c9a66
commit
e856920488
|
@ -198,7 +198,7 @@ void CheckFunctions::checkIgnoredReturnValue()
|
|||
for (const Scope *scope : symbolDatabase->functionScopes) {
|
||||
for (const Token* tok = scope->bodyStart->next(); tok != scope->bodyEnd; tok = tok->next()) {
|
||||
// skip c++11 initialization, ({...})
|
||||
if (Token::Match(tok, "%var%|(|, {"))
|
||||
if (Token::Match(tok, "%var%|(|,|return {"))
|
||||
tok = tok->linkAt(1);
|
||||
else if (Token::Match(tok, "[(<]") && tok->link())
|
||||
tok = tok->link();
|
||||
|
|
|
@ -1175,6 +1175,14 @@ private:
|
|||
" return std::get<0>(c);\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("struct A { int x; };\n"
|
||||
"template <class... Ts>\n"
|
||||
"A f(int x, Ts... xs) {\n"
|
||||
" return {std::move(x), static_cast<int>(xs)...};\n"
|
||||
"}\n"
|
||||
"A g() { return f(1); }\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void memsetZeroBytes() {
|
||||
|
|
Loading…
Reference in New Issue