better fix for #3114 (infinite recursion when operator= is overloaded)
This commit is contained in:
parent
2bc7da2c64
commit
2670525b4f
|
@ -378,6 +378,15 @@ void CheckClass::initializeVarList(const Function &func, std::list<std::string>
|
|||
else if (Token::simpleMatch(ftok, "operator= (") &&
|
||||
ftok->previous()->str() != "::")
|
||||
{
|
||||
// recursive call / calling overloaded function
|
||||
// assume that all variables are initialized
|
||||
if (std::find(callstack.begin(), callstack.end(), ftok->str()) != callstack.end())
|
||||
{
|
||||
/** @todo false negative: just bail */
|
||||
assignAllVar(usage);
|
||||
return;
|
||||
}
|
||||
|
||||
/** @todo check function parameters for overloaded function so we check the right one */
|
||||
// check if member function exists
|
||||
std::list<Function>::const_iterator it;
|
||||
|
@ -392,16 +401,12 @@ void CheckClass::initializeVarList(const Function &func, std::list<std::string>
|
|||
{
|
||||
// member function has implementation
|
||||
if (it->hasBody)
|
||||
{
|
||||
// check for recursion
|
||||
if ((&(*it) != &func))
|
||||
{
|
||||
// initialize variable use list using member function
|
||||
callstack.push_back(ftok->str());
|
||||
initializeVarList(*it, callstack, scope, usage);
|
||||
callstack.pop_back();
|
||||
}
|
||||
}
|
||||
|
||||
// there is a called member function, but it has no implementation, so we assume it initializes everything
|
||||
else
|
||||
|
@ -449,16 +454,12 @@ void CheckClass::initializeVarList(const Function &func, std::list<std::string>
|
|||
{
|
||||
// member function has implementation
|
||||
if (it->hasBody)
|
||||
{
|
||||
// check for recursion
|
||||
if ((&(*it) != &func))
|
||||
{
|
||||
// initialize variable use list using member function
|
||||
callstack.push_back(ftok->str());
|
||||
initializeVarList(*it, callstack, scope, usage);
|
||||
callstack.pop_back();
|
||||
}
|
||||
}
|
||||
|
||||
// there is a called member function, but it has no implementation, so we assume it initializes everything
|
||||
else
|
||||
|
|
Loading…
Reference in New Issue