virtual function call in constructor: don't warn about explicit scoped call
This commit is contained in:
parent
2db7c6e1a3
commit
ee22a325c7
|
@ -2271,6 +2271,8 @@ const std::list<const Token *> & CheckClass::getVirtualFunctionCalls(const Funct
|
||||||
}
|
}
|
||||||
|
|
||||||
if (callFunction->isVirtual()) {
|
if (callFunction->isVirtual()) {
|
||||||
|
if (!callFunction->isPure() && Token::simpleMatch(tok->previous(), "::"))
|
||||||
|
continue;
|
||||||
virtualFunctionCalls.push_back(tok);
|
virtualFunctionCalls.push_back(tok);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6338,6 +6338,13 @@ private:
|
||||||
"A::A()\n"
|
"A::A()\n"
|
||||||
"{f();}\n");
|
"{f();}\n");
|
||||||
ASSERT_EQUALS("[test.cpp:7] -> [test.cpp:3]: (warning) Call of virtual function 'f' in constructor.\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:7] -> [test.cpp:3]: (warning) Call of virtual function 'f' in constructor.\n", errout.str());
|
||||||
|
|
||||||
|
checkVirtualFunctionCall("class A\n"
|
||||||
|
"{\n"
|
||||||
|
" A() { A::f(); }\n"
|
||||||
|
" virtual void f() {}\n"
|
||||||
|
"};\n");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void pureVirtualFunctionCall() {
|
void pureVirtualFunctionCall() {
|
||||||
|
|
Loading…
Reference in New Issue