Fixed #10531 (FP unreadVariable with reference and *=)
This commit is contained in:
parent
a838cb65fb
commit
1f01845efb
|
@ -2977,6 +2977,8 @@ struct FwdAnalysis::Result FwdAnalysis::checkRecursive(const Token *expr, const
|
|||
} else if (Token::Match(parent->astParent(), "%assign%") && !parent->astParent()->astParent() && parent == parent->astParent()->astOperand1()) {
|
||||
if (mWhat == What::Reassign)
|
||||
return Result(Result::Type::BAILOUT, parent->astParent());
|
||||
if (mWhat == What::UnusedValue && (!parent->valueType() || parent->valueType()->reference != Reference::None))
|
||||
return Result(Result::Type::BAILOUT, parent->astParent());
|
||||
continue;
|
||||
} else if (mWhat == What::UnusedValue && parent->isUnaryOp("&") && Token::Match(parent->astParent(), "[,(]")) {
|
||||
// Pass variable to function the writes it
|
||||
|
|
|
@ -119,6 +119,7 @@ private:
|
|||
TEST_CASE(localvar57); // #8974 - increment
|
||||
TEST_CASE(localvar58); // #9901 - increment false positive
|
||||
TEST_CASE(localvar59); // #9737
|
||||
TEST_CASE(localvar60);
|
||||
TEST_CASE(localvarloops); // loops
|
||||
TEST_CASE(localvaralias1);
|
||||
TEST_CASE(localvaralias2); // ticket #1637
|
||||
|
@ -3191,6 +3192,16 @@ private:
|
|||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void localvar60() { // #10531
|
||||
functionVariableUsage("void Scale(double scale) {\n"
|
||||
" for (int i = 0; i < m_points.size(); ++i) {\n"
|
||||
" auto& p = m_points[i];\n"
|
||||
" p += scale;\n"
|
||||
" }\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void localvarloops() {
|
||||
// loops
|
||||
functionVariableUsage("void fun(int c) {\n"
|
||||
|
|
Loading…
Reference in New Issue