diff --git a/lib/checkcondition.cpp b/lib/checkcondition.cpp index fcec7bb3f..454807756 100644 --- a/lib/checkcondition.cpp +++ b/lib/checkcondition.cpp @@ -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)) { diff --git a/test/testcondition.cpp b/test/testcondition.cpp index 8dc0f7c3b..cb16f8d27 100644 --- a/test/testcondition.cpp +++ b/test/testcondition.cpp @@ -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"