Fixed #8199 (false negative: (warning) Same condition '...', second condition is always false)
This commit is contained in:
parent
e5e6f37e41
commit
35736364f8
@ -551,7 +551,7 @@ void CheckCondition::multiCondition2()
|
|||||||
tokens2.pop();
|
tokens2.pop();
|
||||||
if (!secondCondition)
|
if (!secondCondition)
|
||||||
continue;
|
continue;
|
||||||
if (secondCondition->str() == "||") {
|
if (secondCondition->str() == "||" || secondCondition->str() == "&&") {
|
||||||
tokens2.push(secondCondition->astOperand1());
|
tokens2.push(secondCondition->astOperand1());
|
||||||
tokens2.push(secondCondition->astOperand2());
|
tokens2.push(secondCondition->astOperand2());
|
||||||
} else if (isSameExpression(_tokenizer->isCPP(), true, cond1, secondCondition, _settings->library, true)) {
|
} else if (isSameExpression(_tokenizer->isCPP(), true, cond1, secondCondition, _settings->library, true)) {
|
||||||
|
@ -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());
|
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"
|
check("void f(int x) {\n"
|
||||||
" if (x > 100) { return; }\n"
|
" if (x > 100) { return; }\n"
|
||||||
" if (abc) {}\n"
|
" if (abc) {}\n"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user