Fixed #7049 (valueflow: value is not known after case)
This commit is contained in:
parent
4ad246f56f
commit
37dbebb093
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue