File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -48,6 +48,7 @@ class CPPCHECKLIB CheckCondition : public Check {
4848 CheckCondition checkCondition (tokenizer, settings, errorLogger);
4949 checkCondition.multiCondition ();
5050 checkCondition.clarifyCondition (); // not simplified because ifAssign
51+ checkCondition.oppositeInnerCondition ();
5152 }
5253
5354 /* * @brief Run checks against the simplified token list */
@@ -56,7 +57,6 @@ class CPPCHECKLIB CheckCondition : public Check {
5657 checkCondition.assignIf ();
5758 checkCondition.checkBadBitmaskCheck ();
5859 checkCondition.comparison ();
59- checkCondition.oppositeInnerCondition ();
6060 checkCondition.checkIncorrectLogicOperator ();
6161 checkCondition.checkModuloAlwaysTrueFalse ();
6262 checkCondition.alwaysTrueFalse ();
Original file line number Diff line number Diff line change @@ -1309,6 +1309,23 @@ class TestCondition : public TestFixture {
13091309 " }\n "
13101310 " }" );
13111311 ASSERT_EQUALS (" " , errout.str ());
1312+
1313+ // #6227 - FP caused by simplifications of casts and known variables
1314+ check (" void foo(A *a) {\n "
1315+ " if(a) {\n "
1316+ " B *b = dynamic_cast<B*>(a);\n "
1317+ " if(!b) {}\n "
1318+ " }\n "
1319+ " }" );
1320+ ASSERT_EQUALS (" " , errout.str ());
1321+
1322+ check (" void foo(int a) {\n "
1323+ " if(a) {\n "
1324+ " int b = a;\n "
1325+ " if(!b) {}\n "
1326+ " }\n "
1327+ " }" );
1328+ TODO_ASSERT_EQUALS (" error" , " " , errout.str ());
13121329 }
13131330
13141331 // clarify conditions with = and comparison
You can’t perform that action at this time.
0 commit comments