diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index b8cde1f38..6ac247684 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -5085,7 +5085,7 @@ static const Token * findEndOfFunctionCallForParameter(const Token * parameterTo if (!parameterToken) return nullptr; const Token * parent = parameterToken->astParent(); - while (parent && !parent->isOp() && parent->str() != "(") + while (parent && !parent->isOp() && !Token::Match(parent, "[({]")) parent = parent->astParent(); if (!parent) return nullptr; diff --git a/test/testother.cpp b/test/testother.cpp index aa09d83ad..074fecc87 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -248,6 +248,7 @@ private: TEST_CASE(doubleMoveMemberInitialization1); TEST_CASE(doubleMoveMemberInitialization2); TEST_CASE(doubleMoveMemberInitialization3); // #9974 + TEST_CASE(doubleMoveMemberInitialization4); TEST_CASE(moveAndAssign1); TEST_CASE(moveAndAssign2); TEST_CASE(moveAssignMoveAssign); @@ -10503,6 +10504,16 @@ private: ASSERT_EQUALS("", errout.str()); } + void doubleMoveMemberInitialization4() { // #11440 + check("struct S { void f(int); };\n" + "struct T {\n" + " T(int c, S&& d) : c{ c }, d{ std::move(d) } { d.f(c); }\n" + " int c;\n" + " S d;\n" + "};\n"); + ASSERT_EQUALS("[test.cpp:3]: (warning, inconclusive) Access of moved variable 'd'.\n", errout.str()); + } + void moveAndAssign1() { check("A g(A a);\n" "void f() {\n"