CheckClass::virtualDestructorError and a variation of CheckNullPointer::nullPointerError would print inconclusive,warning messages altough no --enable=warning was given. Fix.
This commit is contained in:
parent
0b3751520b
commit
01e5f14bf8
|
@ -1647,14 +1647,16 @@ void CheckClass::virtualDestructor()
|
|||
|
||||
void CheckClass::virtualDestructorError(const Token *tok, const std::string &Base, const std::string &Derived, bool inconclusive)
|
||||
{
|
||||
if (inconclusive)
|
||||
reportError(tok, Severity::warning, "virtualDestructor", "Class '" + Base + "' which has virtual members does not have a virtual destructor.", CWE404, true);
|
||||
else
|
||||
if (inconclusive) {
|
||||
if (_settings->isEnabled("warning"))
|
||||
reportError(tok, Severity::warning, "virtualDestructor", "Class '" + Base + "' which has virtual members does not have a virtual destructor.", CWE404, true);
|
||||
} else {
|
||||
reportError(tok, Severity::error, "virtualDestructor", "Class '" + Base + "' which is inherited by class '" + Derived + "' does not have a virtual destructor.\n"
|
||||
"Class '" + Base + "' which is inherited by class '" + Derived + "' does not have a virtual destructor. "
|
||||
"If you destroy instances of the derived class by deleting a pointer that points to the base class, only "
|
||||
"the destructor of the base class is executed. Thus, dynamic memory that is managed by the derived class "
|
||||
"could leak. This can be avoided by adding a virtual destructor to the base class.", CWE404, false);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
|
|
@ -487,6 +487,8 @@ void CheckNullPointer::nullPointerError(const Token *tok, const std::string &var
|
|||
|
||||
void CheckNullPointer::nullPointerError(const Token *tok, const std::string &varname, const Token* nullCheck, bool inconclusive)
|
||||
{
|
||||
if (! _settings->isEnabled("warning"))
|
||||
return;
|
||||
std::list<const Token*> callstack;
|
||||
callstack.push_back(tok);
|
||||
callstack.push_back(nullCheck);
|
||||
|
|
|
@ -1893,6 +1893,7 @@ private:
|
|||
errout.str("");
|
||||
|
||||
settings0.inconclusive = inconclusive;
|
||||
settings0.addEnabled("warning");
|
||||
|
||||
// Tokenize..
|
||||
Tokenizer tokenizer(&settings0, this);
|
||||
|
|
Loading…
Reference in New Issue