Disabled checkComparisonOfBoolWithBool since there are false positives. Ticket #2617
This commit is contained in:
parent
28df610a6e
commit
52be4a5925
|
@ -2323,6 +2323,11 @@ void CheckOther::comparisonOfTwoFuncsReturningBoolError(const Token *tok, const
|
||||||
|
|
||||||
void CheckOther::checkComparisonOfBoolWithBool()
|
void CheckOther::checkComparisonOfBoolWithBool()
|
||||||
{
|
{
|
||||||
|
// FIXME: This checking is "experimental" because of the false positives
|
||||||
|
// when self checking lib/tokenize.cpp (#2617)
|
||||||
|
if (!_settings->experimental)
|
||||||
|
return;
|
||||||
|
|
||||||
if (!_settings->isEnabled("style"))
|
if (!_settings->isEnabled("style"))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -4080,29 +4080,32 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
void checkComparisonOfBoolWithBool() {
|
void checkComparisonOfBoolWithBool() {
|
||||||
check("void f(){\n"
|
const char code[] = "void f(){\n"
|
||||||
" int temp = 4;\n"
|
" int temp = 4;\n"
|
||||||
" bool b = compare2(6);\n"
|
" bool b = compare2(6);\n"
|
||||||
" bool a = compare1(4);\n"
|
" bool a = compare1(4);\n"
|
||||||
" if(b > a){\n"
|
" if(b > a){\n"
|
||||||
" printf(\"foo\");\n"
|
" printf(\"foo\");\n"
|
||||||
" }\n"
|
" }\n"
|
||||||
"}\n"
|
"}\n"
|
||||||
"bool compare1(int temp){\n"
|
"bool compare1(int temp){\n"
|
||||||
" if(temp==4){\n"
|
" if(temp==4){\n"
|
||||||
" return true;\n"
|
" return true;\n"
|
||||||
" }\n"
|
" }\n"
|
||||||
" else\n"
|
" else\n"
|
||||||
" return false;\n"
|
" return false;\n"
|
||||||
"}\n"
|
"}\n"
|
||||||
"bool compare2(int temp){\n"
|
"bool compare2(int temp){\n"
|
||||||
" if(temp == 5){\n"
|
" if(temp == 5){\n"
|
||||||
" return true;\n"
|
" return true;\n"
|
||||||
" }\n"
|
" }\n"
|
||||||
" else\n"
|
" else\n"
|
||||||
" return false;\n"
|
" return false;\n"
|
||||||
"}\n");
|
"}\n";
|
||||||
|
check(code, "test.cpp", true);
|
||||||
ASSERT_EQUALS("[test.cpp:5]: (style) Comparison of a variable having boolean value using relational (<, >, <= or >=) operator.\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:5]: (style) Comparison of a variable having boolean value using relational (<, >, <= or >=) operator.\n", errout.str());
|
||||||
|
check(code, "test.cpp");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void sizeofForNumericParameter() {
|
void sizeofForNumericParameter() {
|
||||||
|
|
Loading…
Reference in New Issue