Symbol database: Skip bail out in constructors if a virtual function might be called because that would be undefined behaviour. Ticket: #1895

This commit is contained in:
Robert Reif 2010-09-14 07:16:53 +02:00 committed by Daniel Marjamäki
parent d3dcb5ab1c
commit 0153dccb66
2 changed files with 7 additions and 2 deletions

View File

@ -991,8 +991,13 @@ void CheckClass::SpaceInfo::initializeVarList(const Func &func, std::list<std::s
else else
{ {
// could be a base class virtual function, so we assume it initializes everything // could be a base class virtual function, so we assume it initializes everything
if (isBaseClassFunc(ftok)) if (func.type != Func::Constructor && isBaseClassFunc(ftok))
{
/** @todo False Negative: we should look at the base class functions to see if they
* call any derived class virtual functions that change the derived class state
*/
assignAllVar(); assignAllVar();
}
// has friends, so we assume it initializes everything // has friends, so we assume it initializes everything
if (!friendList.empty()) if (!friendList.empty())

View File

@ -1868,7 +1868,7 @@ private:
"private:\n" "private:\n"
" int i;\n" " int i;\n"
"};\n"); "};\n");
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("[test.cpp:4]: (style) Member variable not initialized in the constructor 'Fred::i'\n", errout.str());
// Unknown non-member function // Unknown non-member function
checkUninitVar("class Fred\n" checkUninitVar("class Fred\n"