Fixed #8199 (false negative: (warning) Same condition '...', second condition is always false)

This commit is contained in:
Daniel Marjamäki 2017-09-05 22:45:28 +02:00
parent e5e6f37e41
commit 35736364f8
2 changed files with 7 additions and 1 deletions

View File

@ -551,7 +551,7 @@ void CheckCondition::multiCondition2()
tokens2.pop();
if (!secondCondition)
continue;
if (secondCondition->str() == "||") {
if (secondCondition->str() == "||" || secondCondition->str() == "&&") {
tokens2.push(secondCondition->astOperand1());
tokens2.push(secondCondition->astOperand2());
} else if (isSameExpression(_tokenizer->isCPP(), true, cond1, secondCondition, _settings->library, true)) {

View File

@ -1778,6 +1778,12 @@ private:
"}");
ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:3]: (warning) Same condition 'x>100', second condition is always false\n", errout.str());
check("void f(int x) {\n"
" if (x > 100) { return; }\n"
" if (x > 100 && y > 100) {}\n"
"}");
ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:3]: (warning) Same condition 'x>100', second condition is always false\n", errout.str());
check("void f(int x) {\n"
" if (x > 100) { return; }\n"
" if (abc) {}\n"