the virtual destructor error message needs to be restricted. marked the checking as inconclusive for now.
This commit is contained in:
parent
fe1fa4022d
commit
82f030df2c
|
@ -1352,6 +1352,13 @@ void CheckClass::operatorEqToSelf()
|
||||||
|
|
||||||
void CheckClass::virtualDestructor()
|
void CheckClass::virtualDestructor()
|
||||||
{
|
{
|
||||||
|
// This error should only be given if:
|
||||||
|
// * base class doesn't have virtual destructor
|
||||||
|
// * derived class has non-empty destructor
|
||||||
|
// * base class is deleted
|
||||||
|
if (!_settings->inconclusive)
|
||||||
|
return;
|
||||||
|
|
||||||
const char pattern_classdecl[] = "class %var% : %var%";
|
const char pattern_classdecl[] = "class %var% : %var%";
|
||||||
|
|
||||||
const Token *derived = _tokenizer->tokens();
|
const Token *derived = _tokenizer->tokens();
|
||||||
|
|
|
@ -1211,7 +1211,7 @@ private:
|
||||||
|
|
||||||
checkVirtualDestructor("class Base { };\n"
|
checkVirtualDestructor("class Base { };\n"
|
||||||
"class Derived : public Base { public: ~Derived() { (void)11; } };");
|
"class Derived : public Base { public: ~Derived() { (void)11; } };");
|
||||||
ASSERT_EQUALS("[test.cpp:1]: (error) Class Base which is inherited by class Derived does not have a virtual destructor\n", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
checkVirtualDestructor("class Base { };\n"
|
checkVirtualDestructor("class Base { };\n"
|
||||||
"class Derived : Base { public: ~Derived() { (void)11; } };");
|
"class Derived : Base { public: ~Derived() { (void)11; } };");
|
||||||
|
@ -1224,11 +1224,11 @@ private:
|
||||||
|
|
||||||
checkVirtualDestructor("class Base { public: ~Base(); };\n"
|
checkVirtualDestructor("class Base { public: ~Base(); };\n"
|
||||||
"class Derived : public Base { public: ~Derived() { (void)11; } };");
|
"class Derived : public Base { public: ~Derived() { (void)11; } };");
|
||||||
ASSERT_EQUALS("[test.cpp:1]: (error) Class Base which is inherited by class Derived does not have a virtual destructor\n", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
checkVirtualDestructor("class Base { public: ~Base(); };\n"
|
checkVirtualDestructor("class Base { public: ~Base(); };\n"
|
||||||
"class Derived : private Fred, public Base { public: ~Derived() { (void)11; } };");
|
"class Derived : private Fred, public Base { public: ~Derived() { (void)11; } };");
|
||||||
ASSERT_EQUALS("[test.cpp:1]: (error) Class Base which is inherited by class Derived does not have a virtual destructor\n", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void virtualDestructor4()
|
void virtualDestructor4()
|
||||||
|
@ -1386,7 +1386,7 @@ private:
|
||||||
" public:\n"
|
" public:\n"
|
||||||
" ~B(){int a;}\n"
|
" ~B(){int a;}\n"
|
||||||
"};\n");
|
"};\n");
|
||||||
ASSERT_EQUALS("[test.cpp:7]: (error) Class AA<double> which is inherited by class B does not have a virtual destructor\n", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void checkUninitVar(const char code[])
|
void checkUninitVar(const char code[])
|
||||||
|
|
Loading…
Reference in New Issue