virtualCallInConstructor: Clarify warning message
This commit is contained in:
parent
b3b364b42f
commit
0d434efc15
|
@ -2291,7 +2291,7 @@ void CheckClass::getFirstVirtualFunctionCallStack(
|
||||||
{
|
{
|
||||||
const Function *callFunction = callToken->function();
|
const Function *callFunction = callToken->function();
|
||||||
if (callFunction->isVirtual() && (!callFunction->isPure() || !callFunction->hasBody())) {
|
if (callFunction->isVirtual() && (!callFunction->isPure() || !callFunction->hasBody())) {
|
||||||
callstack.push_back(callFunction->token);
|
callstack.push_back(callFunction->tokenDef);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
std::map<const Function *, std::list<const Token *> >::const_iterator found = virtualFunctionCallsMap.find(callFunction);
|
std::map<const Function *, std::list<const Token *> >::const_iterator found = virtualFunctionCallsMap.find(callFunction);
|
||||||
|
|
|
@ -6348,6 +6348,13 @@ private:
|
||||||
"{f();}\n");
|
"{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());
|
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"
|
checkVirtualFunctionCall("class A\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" A() { A::f(); }\n"
|
" A() { A::f(); }\n"
|
||||||
|
|
Loading…
Reference in New Issue