fix #2602 (segmentation fault of cppcheck ( class A {A& operator=(const A&); }; ))
This commit is contained in:
parent
4e1ce93104
commit
ba6c2ca310
|
@ -641,20 +641,23 @@ void CheckClass::privateFunctions()
|
|||
for (func = scope->functionList.begin(); func != scope->functionList.end(); ++func)
|
||||
{
|
||||
const Token *ftok = func->start;
|
||||
const Token *etok = ftok->link();
|
||||
|
||||
for (; ftok != etok; ftok = ftok->next())
|
||||
if (ftok)
|
||||
{
|
||||
if (Token::Match(ftok, "%var% ("))
|
||||
const Token *etok = ftok->link();
|
||||
|
||||
for (; ftok != etok; ftok = ftok->next())
|
||||
{
|
||||
// Remove function from FuncList
|
||||
std::list<const Token *>::iterator it = FuncList.begin();
|
||||
while (it != FuncList.end())
|
||||
if (Token::Match(ftok, "%var% ("))
|
||||
{
|
||||
if (ftok->str() == (*it)->str())
|
||||
FuncList.erase(it++);
|
||||
else
|
||||
++it;
|
||||
// Remove function from FuncList
|
||||
std::list<const Token *>::iterator it = FuncList.begin();
|
||||
while (it != FuncList.end())
|
||||
{
|
||||
if (ftok->str() == (*it)->str())
|
||||
FuncList.erase(it++);
|
||||
else
|
||||
++it;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,6 +39,7 @@ private:
|
|||
TEST_CASE(test3);
|
||||
TEST_CASE(test4);
|
||||
TEST_CASE(test5);
|
||||
TEST_CASE(test6); // ticket #2602
|
||||
|
||||
// [ 2236547 ] False positive --style unused function, called via pointer
|
||||
TEST_CASE(func_pointer1);
|
||||
|
@ -225,6 +226,14 @@ private:
|
|||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void test6() // ticket #2602 segmentation fault
|
||||
{
|
||||
check("class A {\n"
|
||||
" A& operator=(const A&);\n"
|
||||
"};\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue