virtual function call in constructor: don't warn about explicit scoped call

This commit is contained in:
Daniel Marjamäki 2018-04-03 14:02:59 +02:00
parent 2db7c6e1a3
commit ee22a325c7
2 changed files with 9 additions and 0 deletions

View File

@ -2271,6 +2271,8 @@ const std::list<const Token *> & CheckClass::getVirtualFunctionCalls(const Funct
}
if (callFunction->isVirtual()) {
if (!callFunction->isPure() && Token::simpleMatch(tok->previous(), "::"))
continue;
virtualFunctionCalls.push_back(tok);
continue;
}

View File

@ -6338,6 +6338,13 @@ private:
"A::A()\n"
"{f();}\n");
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() {