Ticket #9104 - Adde a regression test

This commit is contained in:
orbitcowboy 2022-03-25 17:01:57 +01:00
parent 12cb19bdf2
commit 8d7fe702e0
1 changed files with 21 additions and 0 deletions

View File

@ -2562,6 +2562,27 @@ private:
"Base *base = new Derived;\n" "Base *base = new Derived;\n"
"delete base;"); "delete base;");
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
// #9104
checkVirtualDestructor("struct A\n"
"{\n"
" A() { cout << \"A is constructing\\n\"; }\n"
" ~A() { cout << \"A is destructing\\n\"; }\n"
"};\n"
" \n"
"struct Base {};\n"
" \n"
"struct Derived : Base\n"
"{\n"
" A a;\n"
"};\n"
" \n"
"int main(void)\n"
"{\n"
" Base* p = new Derived();\n"
" delete p;\n"
"}");
ASSERT_EQUALS("[test.cpp:7]: (error) Class 'Base' which is inherited by class 'Derived' does not have a virtual destructor.\n", errout.str());
} }
void virtualDestructor3() { void virtualDestructor3() {