ValueFlow: Fix for valueflow analysis after for loop

This commit is contained in:
Daniel Marjamäki 2015-01-05 14:00:12 +01:00
parent a80101f277
commit c5467766e2
2 changed files with 11 additions and 1 deletions

View File

@ -1480,7 +1480,7 @@ static void valueFlowForLoopSimplifyAfter(Token *fortok, unsigned int varid, con
std::list<ValueFlow::Value> values; std::list<ValueFlow::Value> values;
values.push_back(num); values.push_back(num);
valueFlowForward(fortok->linkAt(1)->linkAt(1), valueFlowForward(fortok->linkAt(1)->linkAt(1)->next(),
endToken, endToken,
var, var,
varid, varid,

View File

@ -1289,6 +1289,16 @@ private:
"}\n"; "}\n";
TODO_ASSERT_EQUALS(true, false, testValueOfX(code, 4U, 20)); TODO_ASSERT_EQUALS(true, false, testValueOfX(code, 4U, 20));
code = "void f() {\n"
" int x;\n"
" for (x = 0; x < 5; x++) {}\n"
" if (x == 5) {\n"
" panic();\n"
" }\n"
" a = x;\n"
"}";
ASSERT_EQUALS(false, testValueOfX(code, 7U, 5));
// 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"