From 40e14f401f7794055d2516fcbe4b232a0a7abda0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Tue, 26 Jan 2016 10:08:21 +0100 Subject: [PATCH] CheckCondition::alwaysTrueFalse: Move to normal checking to catch more problems --- lib/checkcondition.h | 2 +- test/testcondition.cpp | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/checkcondition.h b/lib/checkcondition.h index 200258725..6d86b2fce 100644 --- a/lib/checkcondition.h +++ b/lib/checkcondition.h @@ -51,6 +51,7 @@ public: checkCondition.oppositeInnerCondition(); checkCondition.checkIncorrectLogicOperator(); checkCondition.checkInvalidTestForOverflow(); + checkCondition.alwaysTrueFalse(); } /** @brief Run checks against the simplified token list */ @@ -60,7 +61,6 @@ public: checkCondition.checkBadBitmaskCheck(); checkCondition.comparison(); checkCondition.checkModuloAlwaysTrueFalse(); - checkCondition.alwaysTrueFalse(); } /** mismatching assignment / comparison */ diff --git a/test/testcondition.cpp b/test/testcondition.cpp index e3ff4d4b2..52e876ff3 100644 --- a/test/testcondition.cpp +++ b/test/testcondition.cpp @@ -1596,7 +1596,9 @@ private: " A(x++ == 1);\n" " A(x++ == 2);\n" "}"); - ASSERT_EQUALS("[test.cpp:4]: (style) Condition 'x++==2' is always false\n", errout.str()); + ASSERT_EQUALS("[test.cpp:3]: (style) Condition 'x++==1' is always false\n" + "[test.cpp:4]: (style) Condition 'x++==2' is always false\n", + errout.str()); // Avoid FP when condition comes from macro check("void f() {\n"