Fixed #3868 (false positive: (style) Same expression on both sides of '|'.)
This commit is contained in:
parent
f59078fad9
commit
162a430354
|
@ -2582,10 +2582,10 @@ void CheckOther::complexDuplicateExpressionCheck(const std::list<const Function*
|
||||||
const std::string &toCheck,
|
const std::string &toCheck,
|
||||||
const std::string &alt)
|
const std::string &alt)
|
||||||
{
|
{
|
||||||
std::string statementStart(",|=|return");
|
std::string statementStart(",|=|?|:|return");
|
||||||
if (!alt.empty())
|
if (!alt.empty())
|
||||||
statementStart += "|" + alt;
|
statementStart += "|" + alt;
|
||||||
std::string statementEnd(";|,");
|
std::string statementEnd(";|,|?|:");
|
||||||
if (!alt.empty())
|
if (!alt.empty())
|
||||||
statementEnd += "|" + alt;
|
statementEnd += "|" + alt;
|
||||||
|
|
||||||
|
|
|
@ -109,6 +109,7 @@ private:
|
||||||
TEST_CASE(incorrectLogicOperator3);
|
TEST_CASE(incorrectLogicOperator3);
|
||||||
TEST_CASE(secondAlwaysTrueFalseWhenFirstTrueError);
|
TEST_CASE(secondAlwaysTrueFalseWhenFirstTrueError);
|
||||||
TEST_CASE(incorrectLogicOp_condSwapping);
|
TEST_CASE(incorrectLogicOp_condSwapping);
|
||||||
|
TEST_CASE(sameExpression);
|
||||||
|
|
||||||
TEST_CASE(memsetZeroBytes);
|
TEST_CASE(memsetZeroBytes);
|
||||||
|
|
||||||
|
@ -3064,6 +3065,15 @@ private:
|
||||||
ASSERT_EQUALS("[test.cpp:2]: (warning) Logical conjunction always evaluates to false: x < 1 && x > 3.\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:2]: (warning) Logical conjunction always evaluates to false: x < 1 && x > 3.\n", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void sameExpression() {
|
||||||
|
// #3868 - false positive (same expression on both sides of |)
|
||||||
|
check("void f(int x) {\n"
|
||||||
|
" a = x ? A | B | C\n"
|
||||||
|
" : A | B;\n"
|
||||||
|
"}");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
}
|
||||||
|
|
||||||
void comparisonOfBoolExpressionWithInt1() {
|
void comparisonOfBoolExpressionWithInt1() {
|
||||||
check("void f(int x) {\n"
|
check("void f(int x) {\n"
|
||||||
" if ((x && 0x0f)==6)\n"
|
" if ((x && 0x0f)==6)\n"
|
||||||
|
|
Loading…
Reference in New Issue