Fix issue 8839: FP knownConditionTrueFalse - condition inside a while-clause (#1469)
This commit is contained in:
parent
17a8a4898d
commit
36e663e250
|
@ -1145,6 +1145,7 @@ static void valueFlowTerminatingCondition(TokenList *tokenlist, SymbolDatabase*
|
||||||
const Scope * condScope = nullptr;
|
const Scope * condScope = nullptr;
|
||||||
for(const Scope * parent = condTok->scope();parent;parent = parent->nestedIn) {
|
for(const Scope * parent = condTok->scope();parent;parent = parent->nestedIn) {
|
||||||
if (parent->type == Scope::eIf ||
|
if (parent->type == Scope::eIf ||
|
||||||
|
parent->type == Scope::eWhile ||
|
||||||
parent->type == Scope::eSwitch) {
|
parent->type == Scope::eSwitch) {
|
||||||
condScope = parent;
|
condScope = parent;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -2673,6 +2673,16 @@ private:
|
||||||
" return std::time(0) > maxtime;\n"
|
" return std::time(0) > maxtime;\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
check("void foo(double param) {\n"
|
||||||
|
" while(bar()) {\n"
|
||||||
|
" if (param<0.)\n"
|
||||||
|
" return;\n"
|
||||||
|
" }\n"
|
||||||
|
" if (param<0.)\n"
|
||||||
|
" return;\n"
|
||||||
|
"}\n");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void multiConditionAlwaysTrue() {
|
void multiConditionAlwaysTrue() {
|
||||||
|
|
Loading…
Reference in New Issue