Fixed #9276 (False positive: ValueFlow does not handle return in switch properly.)
This commit is contained in:
parent
c8e1ca7127
commit
e0093c99ce
|
@ -5273,6 +5273,9 @@ static void valueFlowSwitchVariable(TokenList *tokenlist, SymbolDatabase* symbol
|
|||
if (vartok->variable()->scope()) {
|
||||
if (known)
|
||||
values.back().setKnown();
|
||||
|
||||
// FIXME We must check if there is a return. See #9276
|
||||
/*
|
||||
valueFlowForwardVariable(tok->tokAt(3),
|
||||
vartok->variable()->scope()->bodyEnd,
|
||||
vartok->variable(),
|
||||
|
@ -5283,6 +5286,7 @@ static void valueFlowSwitchVariable(TokenList *tokenlist, SymbolDatabase* symbol
|
|||
tokenlist,
|
||||
errorLogger,
|
||||
settings);
|
||||
*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2743,16 +2743,16 @@ private:
|
|||
" a = x;\n" // <- x can be 14
|
||||
"}";
|
||||
ASSERT_EQUALS(true, testConditionalValueOfX(code, 2U, 14));
|
||||
ASSERT_EQUALS(true, testConditionalValueOfX(code, 4U, 14));
|
||||
ASSERT_EQUALS(true, testConditionalValueOfX(code, 6U, 14));
|
||||
TODO_ASSERT_EQUALS(true, false, testConditionalValueOfX(code, 4U, 14));
|
||||
TODO_ASSERT_EQUALS(true, false, testConditionalValueOfX(code, 6U, 14));
|
||||
|
||||
ValueFlow::Value value1 = valueOfTok(code, "-");
|
||||
ASSERT_EQUALS(13, value1.intvalue);
|
||||
ASSERT(!value1.isKnown());
|
||||
|
||||
ValueFlow::Value value2 = valueOfTok(code, "+");
|
||||
ASSERT_EQUALS(16, value2.intvalue);
|
||||
ASSERT(value2.isKnown());
|
||||
TODO_ASSERT_EQUALS(16, 0, value2.intvalue);
|
||||
TODO_ASSERT_EQUALS(true, false, value2.isKnown());
|
||||
}
|
||||
|
||||
void valueFlowForLoop() {
|
||||
|
|
Loading…
Reference in New Issue