Fix issue 8839: FP knownConditionTrueFalse - condition inside a while-clause (#1469)

This commit is contained in:
Paul Fultz II 2018-11-08 23:09:51 -06:00 committed by Daniel Marjamäki
parent 17a8a4898d
commit 36e663e250
2 changed files with 11 additions and 0 deletions

View File

@ -1145,6 +1145,7 @@ static void valueFlowTerminatingCondition(TokenList *tokenlist, SymbolDatabase*
const Scope * condScope = nullptr;
for(const Scope * parent = condTok->scope();parent;parent = parent->nestedIn) {
if (parent->type == Scope::eIf ||
parent->type == Scope::eWhile ||
parent->type == Scope::eSwitch) {
condScope = parent;
break;

View File

@ -2673,6 +2673,16 @@ private:
" return std::time(0) > maxtime;\n"
"}\n");
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() {