Disabled checkComparisonOfBoolWithBool since there are false positives. Ticket #2617

This commit is contained in:
Daniel Marjamäki 2012-09-28 19:11:36 +02:00
parent 28df610a6e
commit 52be4a5925
2 changed files with 30 additions and 22 deletions

View File

@ -2323,6 +2323,11 @@ void CheckOther::comparisonOfTwoFuncsReturningBoolError(const Token *tok, const
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"))
return;

View File

@ -4080,29 +4080,32 @@ private:
}
void checkComparisonOfBoolWithBool() {
check("void f(){\n"
" int temp = 4;\n"
" bool b = compare2(6);\n"
" bool a = compare1(4);\n"
" if(b > a){\n"
" printf(\"foo\");\n"
" }\n"
"}\n"
"bool compare1(int temp){\n"
" if(temp==4){\n"
" return true;\n"
" }\n"
" else\n"
" return false;\n"
"}\n"
"bool compare2(int temp){\n"
" if(temp == 5){\n"
" return true;\n"
" }\n"
" else\n"
" return false;\n"
"}\n");
const char code[] = "void f(){\n"
" int temp = 4;\n"
" bool b = compare2(6);\n"
" bool a = compare1(4);\n"
" if(b > a){\n"
" printf(\"foo\");\n"
" }\n"
"}\n"
"bool compare1(int temp){\n"
" if(temp==4){\n"
" return true;\n"
" }\n"
" else\n"
" return false;\n"
"}\n"
"bool compare2(int temp){\n"
" if(temp == 5){\n"
" return true;\n"
" }\n"
" else\n"
" return false;\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());
check(code, "test.cpp");
ASSERT_EQUALS("", errout.str());
}
void sizeofForNumericParameter() {