Skip to content

Commit 40e14f4

Browse files
committed
CheckCondition::alwaysTrueFalse: Move to normal checking to catch more problems
1 parent a391bca commit 40e14f4

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

lib/checkcondition.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ class CPPCHECKLIB CheckCondition : public Check {
5151
checkCondition.oppositeInnerCondition();
5252
checkCondition.checkIncorrectLogicOperator();
5353
checkCondition.checkInvalidTestForOverflow();
54+
checkCondition.alwaysTrueFalse();
5455
}
5556

5657
/** @brief Run checks against the simplified token list */
@@ -60,7 +61,6 @@ class CPPCHECKLIB CheckCondition : public Check {
6061
checkCondition.checkBadBitmaskCheck();
6162
checkCondition.comparison();
6263
checkCondition.checkModuloAlwaysTrueFalse();
63-
checkCondition.alwaysTrueFalse();
6464
}
6565

6666
/** mismatching assignment / comparison */

test/testcondition.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1596,7 +1596,9 @@ class TestCondition : public TestFixture {
15961596
" A(x++ == 1);\n"
15971597
" A(x++ == 2);\n"
15981598
"}");
1599-
ASSERT_EQUALS("[test.cpp:4]: (style) Condition 'x++==2' is always false\n", errout.str());
1599+
ASSERT_EQUALS("[test.cpp:3]: (style) Condition 'x++==1' is always false\n"
1600+
"[test.cpp:4]: (style) Condition 'x++==2' is always false\n",
1601+
errout.str());
16001602

16011603
// Avoid FP when condition comes from macro
16021604
check("void f() {\n"

0 commit comments

Comments
 (0)