diff --git a/lib/checkfunctions.cpp b/lib/checkfunctions.cpp index 5184d0ecb..9502e535a 100644 --- a/lib/checkfunctions.cpp +++ b/lib/checkfunctions.cpp @@ -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(); diff --git a/test/testfunctions.cpp b/test/testfunctions.cpp index 9b5535350..04dbc49ef 100644 --- a/test/testfunctions.cpp +++ b/test/testfunctions.cpp @@ -1175,6 +1175,14 @@ private: " return std::get<0>(c);\n" "}\n"); ASSERT_EQUALS("", errout.str()); + + check("struct A { int x; };\n" + "template \n" + "A f(int x, Ts... xs) {\n" + " return {std::move(x), static_cast(xs)...};\n" + "}\n" + "A g() { return f(1); }\n"); + ASSERT_EQUALS("", errout.str()); } void memsetZeroBytes() {