Change unusedScopedObject severity from error to style. The checker does not determine that there is ub or wrong behaviour.

This commit is contained in:
Daniel Marjamäki 2015-06-20 11:22:15 +02:00
parent 0a49b033ba
commit 63f39ea48f
2 changed files with 11 additions and 9 deletions

View File

@ -1969,9 +1969,11 @@ void CheckOther::mathfunctionCallWarning(const Token *tok, const std::string& ol
void CheckOther::checkMisusedScopedObject()
{
// Skip this check for .c files
if (_tokenizer->isC()) {
if (_tokenizer->isC())
return;
if (!_settings->isEnabled("style"))
return;
}
const SymbolDatabase * const symbolDatabase = _tokenizer->getSymbolDatabase();
const std::size_t functions = symbolDatabase->functionScopes.size();
@ -1993,7 +1995,7 @@ void CheckOther::checkMisusedScopedObject()
void CheckOther::misusedScopeObjectError(const Token *tok, const std::string& varname)
{
reportError(tok, Severity::error,
reportError(tok, Severity::style,
"unusedScopedObject", "Instance of '" + varname + "' object is destroyed immediately.");
}

View File

@ -3436,7 +3436,7 @@ private:
" return 0;\n"
"}\n"
);
ASSERT_EQUALS("[test.cpp:15]: (error) Instance of 'Lock' object is destroyed immediately.\n", errout.str());
ASSERT_EQUALS("[test.cpp:15]: (style) Instance of 'Lock' object is destroyed immediately.\n", errout.str());
}
void trac3693() {
@ -3485,7 +3485,7 @@ private:
" return 0 ;\n"
"}\n"
);
ASSERT_EQUALS("[test.cpp:4]: (error) Instance of 'NotAFunction' object is destroyed immediately.\n", errout.str());
ASSERT_EQUALS("[test.cpp:4]: (style) Instance of 'NotAFunction' object is destroyed immediately.\n", errout.str());
}
void testMisusedScopeObjectPicksStruct() {
@ -3496,7 +3496,7 @@ private:
" return true ;\n"
"}\n"
);
ASSERT_EQUALS("[test.cpp:4]: (error) Instance of 'NotAClass' object is destroyed immediately.\n", errout.str());
ASSERT_EQUALS("[test.cpp:4]: (style) Instance of 'NotAClass' object is destroyed immediately.\n", errout.str());
}
void testMisusedScopeObjectDoesNotPickIf() {
@ -3551,7 +3551,7 @@ private:
" do_something();\n"
"}\n"
);
ASSERT_EQUALS("[test.cpp:7]: (error) Instance of 'Foo' object is destroyed immediately.\n", errout.str());
ASSERT_EQUALS("[test.cpp:7]: (style) Instance of 'Foo' object is destroyed immediately.\n", errout.str());
}
void testMisusedScopeObjectDoesNotPickUsedObject() {
@ -3580,7 +3580,7 @@ private:
"}\n";
check(code, "test.cpp");
ASSERT_EQUALS("[test.cpp:7]: (error) Instance of 'cb_watch_bool' object is destroyed immediately.\n", errout.str());
ASSERT_EQUALS("[test.cpp:7]: (style) Instance of 'cb_watch_bool' object is destroyed immediately.\n", errout.str());
check(code, "test.c");
ASSERT_EQUALS("", errout.str());
@ -3627,7 +3627,7 @@ private:
" Foo(char x, int y) { }\n"
"};\n";
check(code, "test.cpp");
ASSERT_EQUALS("[test.cpp:4]: (error) Instance of 'Foo' object is destroyed immediately.\n", errout.str());
ASSERT_EQUALS("[test.cpp:4]: (style) Instance of 'Foo' object is destroyed immediately.\n", errout.str());
}
void testMisusedScopeObjectNoCodeAfter() {