diff --git a/lib/checkcondition.h b/lib/checkcondition.h index 9b5300260..cc9e7805a 100644 --- a/lib/checkcondition.h +++ b/lib/checkcondition.h @@ -48,6 +48,7 @@ public: CheckCondition checkCondition(tokenizer, settings, errorLogger); checkCondition.multiCondition(); checkCondition.clarifyCondition(); // not simplified because ifAssign + checkCondition.oppositeInnerCondition(); } /** @brief Run checks against the simplified token list */ @@ -56,7 +57,6 @@ public: checkCondition.assignIf(); checkCondition.checkBadBitmaskCheck(); checkCondition.comparison(); - checkCondition.oppositeInnerCondition(); checkCondition.checkIncorrectLogicOperator(); checkCondition.checkModuloAlwaysTrueFalse(); checkCondition.alwaysTrueFalse(); diff --git a/test/testcondition.cpp b/test/testcondition.cpp index 1311b7814..81c7956e6 100644 --- a/test/testcondition.cpp +++ b/test/testcondition.cpp @@ -1309,6 +1309,23 @@ private: " }\n" "}"); ASSERT_EQUALS("", errout.str()); + + // #6227 - FP caused by simplifications of casts and known variables + check("void foo(A *a) {\n" + " if(a) {\n" + " B *b = dynamic_cast(a);\n" + " if(!b) {}\n" + " }\n" + "}"); + ASSERT_EQUALS("", errout.str()); + + check("void foo(int a) {\n" + " if(a) {\n" + " int b = a;\n" + " if(!b) {}\n" + " }\n" + "}"); + TODO_ASSERT_EQUALS("error", "", errout.str()); } // clarify conditions with = and comparison