Fixed #6227 (False positive (oppositeInnerCondition) - if (!dynamic_cast<>))
This commit is contained in:
parent
5cc744b941
commit
64b72bd6e5
|
@ -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();
|
||||
|
|
|
@ -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<B*>(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
|
||||
|
|
Loading…
Reference in New Issue