Fixed #5549 (ValueFlow: Handle static variables better in valueFlowAfterAssign)
This commit is contained in:
parent
568b9677d7
commit
30fa187b30
|
@ -490,6 +490,12 @@ static void valueFlowAfterAssign(TokenList *tokenlist, ErrorLogger *errorLogger,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (var->isStatic()) {
|
||||||
|
if (settings->debugwarnings)
|
||||||
|
bailout(tokenlist, errorLogger, tok2, "variable " + var->nameToken()->str() + " bailout when conditional code that contains var is seen");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
// Remove conditional values
|
// Remove conditional values
|
||||||
std::list<ValueFlow::Value>::iterator it;
|
std::list<ValueFlow::Value>::iterator it;
|
||||||
for (it = values.begin(); it != values.end();) {
|
for (it = values.begin(); it != values.end();) {
|
||||||
|
|
|
@ -498,6 +498,13 @@ private:
|
||||||
"}";
|
"}";
|
||||||
ASSERT_EQUALS(false, testValueOfX(code, 4U, 2));
|
ASSERT_EQUALS(false, testValueOfX(code, 4U, 2));
|
||||||
|
|
||||||
|
code = "void f() {\n"
|
||||||
|
" static int x = 0;\n"
|
||||||
|
" if (x==0) x = getX();\n"
|
||||||
|
" return x;\n"
|
||||||
|
"}";
|
||||||
|
ASSERT_EQUALS(false, testValueOfX(code, 4U, 0));
|
||||||
|
|
||||||
// function
|
// function
|
||||||
code = "void f() {\n"
|
code = "void f() {\n"
|
||||||
" char *x = 0;\n"
|
" char *x = 0;\n"
|
||||||
|
|
Loading…
Reference in New Issue