Fixed #9851 (FP virtualDestructor - private virtual dtor)
This commit is contained in:
parent
040da4ff32
commit
30d3643bb8
|
@ -1608,9 +1608,7 @@ void CheckClass::virtualDestructor()
|
||||||
if (scope->definedType->derivedFrom.empty()) {
|
if (scope->definedType->derivedFrom.empty()) {
|
||||||
if (printInconclusive) {
|
if (printInconclusive) {
|
||||||
const Function *destructor = scope->getDestructor();
|
const Function *destructor = scope->getDestructor();
|
||||||
if (destructor) {
|
if (destructor && !destructor->hasVirtualSpecifier() && destructor->access == AccessControl::Public) {
|
||||||
if (!((destructor->hasVirtualSpecifier() && destructor->access == AccessControl::Public) ||
|
|
||||||
(destructor->access == AccessControl::Protected))) {
|
|
||||||
for (const Function &func : scope->functionList) {
|
for (const Function &func : scope->functionList) {
|
||||||
if (func.hasVirtualSpecifier()) {
|
if (func.hasVirtualSpecifier()) {
|
||||||
inconclusiveErrors.push_back(destructor);
|
inconclusiveErrors.push_back(destructor);
|
||||||
|
@ -1619,7 +1617,6 @@ void CheckClass::virtualDestructor()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2531,6 +2531,13 @@ private:
|
||||||
" ~Base(){}\n"
|
" ~Base(){}\n"
|
||||||
"};\n", true);
|
"};\n", true);
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
checkVirtualDestructor("class C {\n"
|
||||||
|
"private:\n"
|
||||||
|
" C();\n"
|
||||||
|
" virtual ~C();\n"
|
||||||
|
"};\n", true);
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void checkNoMemset(const char code[]) {
|
void checkNoMemset(const char code[]) {
|
||||||
|
|
Loading…
Reference in New Issue