Fixed #8288 (valueFlowGlobalVar: compound assignments)
This commit is contained in:
parent
e932c44ae6
commit
7699f6432b
|
@ -989,7 +989,7 @@ static void valueFlowGlobalStaticVar(TokenList *tokenList, const Settings *setti
|
|||
continue;
|
||||
if (Token::Match(tok->astParent(), "++|--|&") && !tok->astParent()->astOperand2())
|
||||
vars.erase(tok->variable());
|
||||
else if (tok->astParent()->str() == "=") {
|
||||
else if (tok->astParent()->isAssignmentOp()) {
|
||||
if (tok == tok->astParent()->astOperand1())
|
||||
vars.erase(tok->variable());
|
||||
else if (tokenList->isCPP() && Token::Match(tok->astParent()->tokAt(-2), "& %name% ="))
|
||||
|
|
|
@ -2721,6 +2721,13 @@ private:
|
|||
"}"
|
||||
"void other() { foo(x); }\n";
|
||||
ASSERT_EQUALS(false, testValueOfX(code, 3U, 321));
|
||||
|
||||
code = "static int x = 1;\n" // compound assignment
|
||||
"void f() {\n"
|
||||
" a = x;\n"
|
||||
"}"
|
||||
"void other() { x += b; }\n";
|
||||
ASSERT_EQUALS(false, testValueOfX(code, 3U, 1));
|
||||
}
|
||||
|
||||
void valueFlowInlineAssembly() {
|
||||
|
|
Loading…
Reference in New Issue