diff --git a/lib/checkclass.cpp b/lib/checkclass.cpp index 6dda50185..a0f85051a 100644 --- a/lib/checkclass.cpp +++ b/lib/checkclass.cpp @@ -2271,6 +2271,8 @@ const std::list & CheckClass::getVirtualFunctionCalls(const Funct } if (callFunction->isVirtual()) { + if (!callFunction->isPure() && Token::simpleMatch(tok->previous(), "::")) + continue; virtualFunctionCalls.push_back(tok); continue; } diff --git a/test/testclass.cpp b/test/testclass.cpp index ffdc0c581..41865ae44 100644 --- a/test/testclass.cpp +++ b/test/testclass.cpp @@ -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() {