Skip over lambdas in CheckClass::checkPureVirtualFunctionCall() (#4992)

This commit is contained in:
PKEuS 2015-11-09 20:15:26 +01:00
parent f15f8514f6
commit aca8a69f5e
2 changed files with 20 additions and 7 deletions

View File

@ -2181,6 +2181,9 @@ const std::list<const Token *> & 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 ||

View File

@ -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() {