Fixed #7405 (false positive: (warning) Opposite conditions in nested 'if' blocks lead to a dead code block.)
This commit is contained in:
parent
4ca004c836
commit
e5e6f37e41
|
@ -593,6 +593,13 @@ void CheckCondition::multiCondition2()
|
|||
(!tok->varId() && nonlocal)) {
|
||||
if (Token::Match(tok, "%name% %assign%|++|--"))
|
||||
break;
|
||||
if (Token::Match(tok->astParent(), "*|.|[")) {
|
||||
const Token *parent = tok;
|
||||
while (Token::Match(parent->astParent(), ".|[") || (Token::simpleMatch(parent->astParent(), "*") && !parent->astParent()->astOperand2()))
|
||||
parent = parent->astParent();
|
||||
if (Token::Match(parent->astParent(), "%assign%"))
|
||||
break;
|
||||
}
|
||||
if (Token::Match(tok, "%name% <<|>>") && (!tok->valueType() || !tok->valueType()->isIntegral()))
|
||||
break;
|
||||
if (Token::Match(tok, "%name% [")) {
|
||||
|
|
|
@ -1522,6 +1522,13 @@ private:
|
|||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("void test(float *f) {\n" // #7405
|
||||
" if(*f>10) {\n"
|
||||
" (*f) += 0.1f;\n"
|
||||
" if(*f<10) {}\n"
|
||||
" }\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void oppositeInnerConditionClass() {
|
||||
|
|
Loading…
Reference in New Issue