refactoring: enable the 'suspicious pointer subtraction' checking
This commit is contained in:
parent
6eb16e0f16
commit
ae576be088
|
@ -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();
|
||||
|
|
|
@ -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[])
|
||||
|
|
Loading…
Reference in New Issue