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:
parent
d3dcb5ab1c
commit
0153dccb66
|
@ -991,8 +991,13 @@ void CheckClass::SpaceInfo::initializeVarList(const Func &func, std::list<std::s
|
|||
else
|
||||
{
|
||||
// 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();
|
||||
}
|
||||
|
||||
// has friends, so we assume it initializes everything
|
||||
if (!friendList.empty())
|
||||
|
|
|
@ -1868,7 +1868,7 @@ private:
|
|||
"private:\n"
|
||||
" int i;\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
|
||||
checkUninitVar("class Fred\n"
|
||||
|
|
Loading…
Reference in New Issue