Fixed #7049 (valueflow: value is not known after case)

This commit is contained in:
Daniel Marjamäki 2015-11-08 14:08:47 +01:00
parent 4ad246f56f
commit 37dbebb093
2 changed files with 12 additions and 1 deletions

View File

@ -1105,7 +1105,7 @@ static bool valueFlowForward(Token * const startToken,
}
}
if (Token::Match(tok2, "[;{}] %name% :")) {
if (Token::Match(tok2, "[;{}] %name% :") || tok2->str() == "case") {
for (std::list<ValueFlow::Value>::iterator it = values.begin(); it != values.end(); ++it)
it->changeKnownToPossible();
tok2 = tok2->tokAt(2);

View File

@ -1729,6 +1729,17 @@ private:
"}";
ASSERT(isNotKnownValues(code, "!"));
code = "void f() {\n" // #7049
" int x = 0;\n"
" switch (a) {\n"
" case 1:\n"
" x = 1;\n"
" case 2:\n"
" if (!x) {}\n" // <- possible value
" }\n"
"}";
ASSERT(isNotKnownValues(code, "!"));
code = "void f() {\n"
" int x = 0;\n"
" while (!x) {\n" // <- possible value