Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
chrchr-github committed Feb 9, 2024
1 parent f1744bb commit 2e03976
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/valueflow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5234,6 +5234,8 @@ static void valueFlowAfterMove(TokenList& tokenlist, const SymbolDatabase& symbo
if (endOfFunctionCall) {
if (endOfFunctionCall->str() == ")") {
Token* ternaryColon = endOfFunctionCall->link()->astParent();
while (Token::simpleMatch(ternaryColon, "("))
ternaryColon = ternaryColon->astParent();
if (Token::simpleMatch(ternaryColon, ":")) {
endOfFunctionCall = ternaryColon->astOperand2();
if (Token::simpleMatch(endOfFunctionCall, "("))
Expand Down
9 changes: 9 additions & 0 deletions test/testother.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11169,6 +11169,15 @@ class TestOther : public TestFixture {
" h(b ? gA(std::move(s)) : gB(std::move(s)));\n"
"}\n");
ASSERT_EQUALS("", errout.str());

check("int gA(int, std::string);\n"
"int gB(int, std::string);\n"
"int h(int);\n"
"void f(bool b) {\n"
" std::string s = \"abc\";\n"
" h(b ? h(gA(5, std::move(s))) : h(gB(7, std::move(s))));\n"
"}\n");
ASSERT_EQUALS("", errout.str());
}

void funcArgNamesDifferent() {
Expand Down

0 comments on commit 2e03976

Please sign in to comment.