#6069 False positive incorrectLogicOperator due to dynamic_cast. Run CheckCondition::checkIncorrectLogicOperator on non-simplified tokenlist.
This commit is contained in:
parent
9085fdc156
commit
c5673612e2
|
@ -49,6 +49,7 @@ public:
|
||||||
checkCondition.multiCondition();
|
checkCondition.multiCondition();
|
||||||
checkCondition.clarifyCondition(); // not simplified because ifAssign
|
checkCondition.clarifyCondition(); // not simplified because ifAssign
|
||||||
checkCondition.oppositeInnerCondition();
|
checkCondition.oppositeInnerCondition();
|
||||||
|
checkCondition.checkIncorrectLogicOperator();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @brief Run checks against the simplified token list */
|
/** @brief Run checks against the simplified token list */
|
||||||
|
@ -57,7 +58,6 @@ public:
|
||||||
checkCondition.assignIf();
|
checkCondition.assignIf();
|
||||||
checkCondition.checkBadBitmaskCheck();
|
checkCondition.checkBadBitmaskCheck();
|
||||||
checkCondition.comparison();
|
checkCondition.comparison();
|
||||||
checkCondition.checkIncorrectLogicOperator();
|
|
||||||
checkCondition.checkModuloAlwaysTrueFalse();
|
checkCondition.checkModuloAlwaysTrueFalse();
|
||||||
checkCondition.alwaysTrueFalse();
|
checkCondition.alwaysTrueFalse();
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,6 +47,7 @@ private:
|
||||||
TEST_CASE(incorrectLogicOperator6); // char literals
|
TEST_CASE(incorrectLogicOperator6); // char literals
|
||||||
TEST_CASE(incorrectLogicOperator7); // opposite expressions: (expr || !expr)
|
TEST_CASE(incorrectLogicOperator7); // opposite expressions: (expr || !expr)
|
||||||
TEST_CASE(incorrectLogicOperator8); // !
|
TEST_CASE(incorrectLogicOperator8); // !
|
||||||
|
TEST_CASE(incorrectLogicOperator9);
|
||||||
TEST_CASE(secondAlwaysTrueFalseWhenFirstTrueError);
|
TEST_CASE(secondAlwaysTrueFalseWhenFirstTrueError);
|
||||||
TEST_CASE(incorrectLogicOp_condSwapping);
|
TEST_CASE(incorrectLogicOp_condSwapping);
|
||||||
TEST_CASE(testBug5895);
|
TEST_CASE(testBug5895);
|
||||||
|
@ -932,6 +933,15 @@ private:
|
||||||
ASSERT_EQUALS("[test.cpp:2]: (warning) Logical conjunction always evaluates to false: !(i != 10) && !(i != 20).\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:2]: (warning) Logical conjunction always evaluates to false: !(i != 10) && !(i != 20).\n", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void incorrectLogicOperator9() { // #6069 "False positive incorrectLogicOperator due to dynamic_cast"
|
||||||
|
check("class MyType;\n"
|
||||||
|
"class OtherType;\n"
|
||||||
|
"void foo (OtherType* obj) { \n"
|
||||||
|
" assert((!obj) || dynamic_cast<MyType*>(obj));\n"
|
||||||
|
"}");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
}
|
||||||
|
|
||||||
void secondAlwaysTrueFalseWhenFirstTrueError() {
|
void secondAlwaysTrueFalseWhenFirstTrueError() {
|
||||||
check("void f(int x) {\n"
|
check("void f(int x) {\n"
|
||||||
" if (x > 5 && x != 1)\n"
|
" if (x > 5 && x != 1)\n"
|
||||||
|
|
Loading…
Reference in New Issue