refactoring: enable the 'suspicious pointer subtraction' checking

This commit is contained in:
Daniel Marjamäki 2010-05-01 21:43:47 +02:00
parent 6eb16e0f16
commit ae576be088
2 changed files with 6 additions and 6 deletions

View File

@ -1474,12 +1474,12 @@ void CheckClass::virtualDestructor()
void CheckClass::thisSubtractionError(const Token *tok)
{
reportError(tok, Severity::possibleStyle, "thisSubtraction", "Suspicious pointer subtraction");
reportError(tok, Severity::style, "thisSubtraction", "Suspicious pointer subtraction");
}
void CheckClass::thisSubtraction()
{
if (!_settings->_checkCodingStyle || !_settings->inconclusive)
if (!_settings->_checkCodingStyle)
return;
const Token *tok = _tokenizer->tokens();

View File

@ -2123,20 +2123,20 @@ private:
void this_subtraction()
{
checkThisSubtraction("; this-x ;");
ASSERT_EQUALS("[test.cpp:1]: (possible style) Suspicious pointer subtraction\n", errout.str());
ASSERT_EQUALS("[test.cpp:1]: (style) Suspicious pointer subtraction\n", errout.str());
checkThisSubtraction("; *this = *this-x ;");
ASSERT_EQUALS("", errout.str());
checkThisSubtraction("; *this = *this-x ;\n"
"this-x ;");
ASSERT_EQUALS("[test.cpp:2]: (possible style) Suspicious pointer subtraction\n", errout.str());
ASSERT_EQUALS("[test.cpp:2]: (style) Suspicious pointer subtraction\n", errout.str());
checkThisSubtraction("; *this = *this-x ;\n"
"this-x ;\n"
"this-x ;\n");
ASSERT_EQUALS("[test.cpp:2]: (possible style) Suspicious pointer subtraction\n"
"[test.cpp:3]: (possible style) Suspicious pointer subtraction\n", errout.str());
ASSERT_EQUALS("[test.cpp:2]: (style) Suspicious pointer subtraction\n"
"[test.cpp:3]: (style) Suspicious pointer subtraction\n", errout.str());
}
void checkConst(const char code[])