Fix crash with defaulted destructor (#3975)
This commit is contained in:
parent
c4dcfef385
commit
f5313dc519
|
@ -2540,7 +2540,7 @@ const std::list<const Token *> & CheckClass::getVirtualFunctionCalls(const Funct
|
|||
virtualFunctionCallsMap[&function] = std::list<const Token *>();
|
||||
std::list<const Token *> & virtualFunctionCalls = virtualFunctionCallsMap.find(&function)->second;
|
||||
|
||||
if (!function.hasBody())
|
||||
if (!function.hasBody() || !function.functionScope)
|
||||
return virtualFunctionCalls;
|
||||
|
||||
for (const Token *tok = function.arg->link(); tok != function.functionScope->bodyEnd; tok = tok->next()) {
|
||||
|
|
|
@ -7335,6 +7335,17 @@ private:
|
|||
" virtual void f() {}\n"
|
||||
"};\n");
|
||||
ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:3]: (style) Virtual function 'f' is called from constructor 'B()' at line 2. Dynamic binding is not used.\n", errout.str());
|
||||
|
||||
checkVirtualFunctionCall("class S {\n" // don't crash
|
||||
" ~S();\n"
|
||||
"public:\n"
|
||||
" S();\n"
|
||||
"};\n"
|
||||
"S::S() {\n"
|
||||
" typeid(S);\n"
|
||||
"}\n"
|
||||
"S::~S() = default;\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void pureVirtualFunctionCall() {
|
||||
|
|
Loading…
Reference in New Issue