Skip to content

Commit 6f17c16

Browse files
Fix #11751 FP accessMoved after passing value to function (#8646)
1 parent 1d0ff1a commit 6f17c16

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

lib/forwardanalyzer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -845,7 +845,7 @@ namespace {
845845
return Break();
846846
} else if (Token* callTok = callExpr(tok)) {
847847
// TODO: Dont traverse tokens a second time
848-
if (start != callTok && tok != callTok && updateRecursive(callTok->astOperand1()) == Progress::Break)
848+
if (start != callTok && tok != callTok && (tok->str() != "." || tok != callTok->astOperand1()) && updateRecursive(callTok->astOperand1()) == Progress::Break)
849849
return Break();
850850
// Since the call could be an unknown macro, traverse the tokens as a range instead of recursively
851851
if (!Token::simpleMatch(callTok, "( )") &&

test/testvalueflow.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1090,6 +1090,14 @@ class TestValueFlow : public TestFixture {
10901090
" }\n"
10911091
"}\n";
10921092
ASSERT_EQUALS(false, testValueOfX(code, 13U, ValueFlow::Value::MoveKind::MovedVariable));
1093+
1094+
code = "struct S { int f(int); };\n" // #11751
1095+
"S g(S);\n"
1096+
"void h() {\n"
1097+
" S x;\n"
1098+
" g(std::move(x)).f(1);\n"
1099+
"}\n";
1100+
ASSERT_EQUALS(false, testValueOfX(code, 5U, ValueFlow::Value::MoveKind::MovedVariable));
10931101
}
10941102

10951103
void valueFlowCalculations() {

0 commit comments

Comments
 (0)