Fixed #7886 (ValueFlow: endless forloop 'for (i = 0, j = 0; i < sz && j < 9; i++)')
This commit is contained in:
parent
a8788d7fc7
commit
8fe7ee1012
|
@ -2859,12 +2859,12 @@ void ValueFlow::setValues(TokenList *tokenlist, SymbolDatabase* symboldatabase,
|
||||||
valueFlowFunctionReturn(tokenlist, errorLogger);
|
valueFlowFunctionReturn(tokenlist, errorLogger);
|
||||||
valueFlowBitAnd(tokenlist);
|
valueFlowBitAnd(tokenlist);
|
||||||
valueFlowOppositeCondition(symboldatabase, settings);
|
valueFlowOppositeCondition(symboldatabase, settings);
|
||||||
valueFlowForLoop(tokenlist, symboldatabase, errorLogger, settings);
|
|
||||||
valueFlowBeforeCondition(tokenlist, symboldatabase, errorLogger, settings);
|
valueFlowBeforeCondition(tokenlist, symboldatabase, errorLogger, settings);
|
||||||
valueFlowAfterMove(tokenlist, symboldatabase, errorLogger, settings);
|
valueFlowAfterMove(tokenlist, symboldatabase, errorLogger, settings);
|
||||||
valueFlowAfterAssign(tokenlist, symboldatabase, errorLogger, settings);
|
valueFlowAfterAssign(tokenlist, symboldatabase, errorLogger, settings);
|
||||||
valueFlowAfterCondition(tokenlist, symboldatabase, errorLogger, settings);
|
valueFlowAfterCondition(tokenlist, symboldatabase, errorLogger, settings);
|
||||||
valueFlowSwitchVariable(tokenlist, symboldatabase, errorLogger, settings);
|
valueFlowSwitchVariable(tokenlist, symboldatabase, errorLogger, settings);
|
||||||
|
valueFlowForLoop(tokenlist, symboldatabase, errorLogger, settings);
|
||||||
valueFlowSubFunction(tokenlist, errorLogger, settings);
|
valueFlowSubFunction(tokenlist, errorLogger, settings);
|
||||||
valueFlowFunctionDefaultParameter(tokenlist, symboldatabase, errorLogger, settings);
|
valueFlowFunctionDefaultParameter(tokenlist, symboldatabase, errorLogger, settings);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1847,7 +1847,6 @@ private:
|
||||||
"}\n";
|
"}\n";
|
||||||
ASSERT_EQUALS(false, testValueOfX(code, 9U, 11));
|
ASSERT_EQUALS(false, testValueOfX(code, 9U, 11));
|
||||||
|
|
||||||
|
|
||||||
// hang
|
// hang
|
||||||
code = "void f() {\n"
|
code = "void f() {\n"
|
||||||
" for(int i = 0; i < 20; i++)\n"
|
" for(int i = 0; i < 20; i++)\n"
|
||||||
|
@ -1867,6 +1866,14 @@ private:
|
||||||
"}";
|
"}";
|
||||||
ASSERT_EQUALS(false, testValueOfX(code, 6U, 10));
|
ASSERT_EQUALS(false, testValueOfX(code, 6U, 10));
|
||||||
|
|
||||||
|
// #7886 - valueFlowForLoop must be called after valueFlowAfterAssign
|
||||||
|
code = "void f() {\n"
|
||||||
|
" int sz = 4;\n"
|
||||||
|
" int x,y;\n"
|
||||||
|
" for(x=0,y=0; x < sz && y < 10; x++)\n"
|
||||||
|
" a = x;\n" // <- max value is 3
|
||||||
|
"}";
|
||||||
|
ASSERT_EQUALS(true, testValueOfX(code, 5U, 3));
|
||||||
}
|
}
|
||||||
|
|
||||||
void valueFlowSubFunction() {
|
void valueFlowSubFunction() {
|
||||||
|
|
Loading…
Reference in New Issue