diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index 64a48285fdc..696e48b3e1c 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -3296,8 +3296,16 @@ static void valueFlowAfterMove(const TokenList& tokenlist, const SymbolDatabase& ternaryColon = ternaryColon->astParent(); if (Token::simpleMatch(ternaryColon, ":")) { endOfFunctionCall = ternaryColon->astOperand2(); - if (Token::simpleMatch(endOfFunctionCall, "(")) + if (Token::simpleMatch(endOfFunctionCall, "(")) { endOfFunctionCall = endOfFunctionCall->link(); + } else { + Token* next = nextAfterAstRightmostLeaf(endOfFunctionCall); + if (next) + endOfFunctionCall = next; + else + endOfFunctionCall = endOfFunctionCall->next(); + + } } } ValueFlow::Value value; diff --git a/test/testother.cpp b/test/testother.cpp index 73f10cbe76e..5074bfafcb8 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -12861,6 +12861,18 @@ class TestOther : public TestFixture { " h(b ? h(gA(5, std::move(s))) : h(gB(7, std::move(s))));\n" "}\n"); ASSERT_EQUALS("", errout_str()); + + check("int cb(std::string);\n" // #13628 + "void f(bool b, std::string s1) {\n" + " std::string s2 = b ? cb(std::move(s1)) : s1;\n" + "}\n"); + ASSERT_EQUALS("", errout_str()); + + check("int cb(std::string);\n" + "void f(bool b, std::string s1) {\n" + " std::string s2 = b ? cb(std::move(s1)) : s1 + s1;\n" + "}\n"); + ASSERT_EQUALS("", errout_str()); } void movePointerAlias()