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= (") &&
|
else if (Token::simpleMatch(ftok, "operator= (") &&
|
||||||
ftok->previous()->str() != "::")
|
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 */
|
/** @todo check function parameters for overloaded function so we check the right one */
|
||||||
// check if member function exists
|
// check if member function exists
|
||||||
std::list<Function>::const_iterator it;
|
std::list<Function>::const_iterator it;
|
||||||
|
@ -393,14 +402,10 @@ void CheckClass::initializeVarList(const Function &func, std::list<std::string>
|
||||||
// member function has implementation
|
// member function has implementation
|
||||||
if (it->hasBody)
|
if (it->hasBody)
|
||||||
{
|
{
|
||||||
// check for recursion
|
// initialize variable use list using member function
|
||||||
if ((&(*it) != &func))
|
callstack.push_back(ftok->str());
|
||||||
{
|
initializeVarList(*it, callstack, scope, usage);
|
||||||
// initialize variable use list using member function
|
callstack.pop_back();
|
||||||
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
|
// there is a called member function, but it has no implementation, so we assume it initializes everything
|
||||||
|
@ -450,14 +455,10 @@ void CheckClass::initializeVarList(const Function &func, std::list<std::string>
|
||||||
// member function has implementation
|
// member function has implementation
|
||||||
if (it->hasBody)
|
if (it->hasBody)
|
||||||
{
|
{
|
||||||
// check for recursion
|
// initialize variable use list using member function
|
||||||
if ((&(*it) != &func))
|
callstack.push_back(ftok->str());
|
||||||
{
|
initializeVarList(*it, callstack, scope, usage);
|
||||||
// initialize variable use list using member function
|
callstack.pop_back();
|
||||||
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
|
// there is a called member function, but it has no implementation, so we assume it initializes everything
|
||||||
|
|
Loading…
Reference in New Issue