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;
|
||||
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;
|
||||
|
|
|
@ -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() {
|
||||
|
|
Loading…
Reference in New Issue