diff --git a/lib/checkclass.cpp b/lib/checkclass.cpp index 0f49eaef2..024ed6c87 100644 --- a/lib/checkclass.cpp +++ b/lib/checkclass.cpp @@ -2181,6 +2181,9 @@ const std::list & CheckClass::callsPureVirtualFunction(const Func continue; } } + if (tok->scope()->type == Scope::eLambda) + tok = tok->scope()->classEnd->next(); + const Function * callFunction = tok->function(); if (!callFunction || function.nestedIn != callFunction->nestedIn || diff --git a/test/testclass.cpp b/test/testclass.cpp index c68efaf4a..5a31f98a0 100644 --- a/test/testclass.cpp +++ b/test/testclass.cpp @@ -6178,23 +6178,33 @@ private: ASSERT_EQUALS("[test.cpp:7] -> [test.cpp:3]: (warning) Call of pure virtual function 'pure' in constructor.\n", errout.str()); checkPureVirtualFunctionCall("class A\n" - " {\n" - " virtual void pure()=0; \n" - " virtual ~A(); \n" - " int m; \n" + "{\n" + " virtual void pure()=0;\n" + " virtual ~A();\n" + " int m;\n" "};\n" "A::~A()\n" - "{if (b) pure();}\n"); + "{if (b) pure();}"); ASSERT_EQUALS("[test.cpp:8] -> [test.cpp:3]: (warning) Call of pure virtual function 'pure' in destructor.\n", errout.str()); - // ticket # 5831 + // #5831 checkPureVirtualFunctionCall("class abc {\n" "public:\n" " virtual ~abc() throw() {}\n" " virtual void def(void* g) throw () = 0;\n" - "};\n"); + "};"); ASSERT_EQUALS("", errout.str()); + // #4992 + checkPureVirtualFunctionCall("class CMyClass {\n" + " std::function< void(void) > m_callback;\n" + "public:\n" + " CMyClass() {\n" + " m_callback = [this]() { return VirtualMethod(); };\n" + " }\n" + " virtual void VirtualMethod() = 0;\n" + "};"); + ASSERT_EQUALS("", errout.str()); } void pureVirtualFunctionCallOtherClass() {