virtualCallInConstructor: Clarify warning message

This commit is contained in:
Daniel Marjamäki 2018-04-04 13:04:40 +02:00
parent b3b364b42f
commit 0d434efc15
2 changed files with 8 additions and 1 deletions

View File

@ -2291,7 +2291,7 @@ void CheckClass::getFirstVirtualFunctionCallStack(
{
const Function *callFunction = callToken->function();
if (callFunction->isVirtual() && (!callFunction->isPure() || !callFunction->hasBody())) {
callstack.push_back(callFunction->token);
callstack.push_back(callFunction->tokenDef);
return;
}
std::map<const Function *, std::list<const Token *> >::const_iterator found = virtualFunctionCallsMap.find(callFunction);

View File

@ -6348,6 +6348,13 @@ private:
"{f();}\n");
ASSERT_EQUALS("[test.cpp:7] -> [test.cpp:3]: (warning) Virtual function 'f' is called from constructor 'A()' at line 7.\n", errout.str());
checkVirtualFunctionCall("class A {\n"
" virtual int f();\n"
" A() {f();}\n"
"};\n"
"int A::f() { return 1; }\n");
ASSERT_EQUALS("[test.cpp:3] -> [test.cpp:2]: (warning) Virtual function 'f' is called from constructor 'A()' at line 3.\n", errout.str());
checkVirtualFunctionCall("class A\n"
"{\n"
" A() { A::f(); }\n"