Symbol database: The symbol database has a bug where it can find an out of line constructor when looking for a destructor. Ticket: #2272

This commit is contained in:
Robert Reif 2010-12-03 07:35:06 +01:00 committed by Daniel Marjamäki
parent 8118e4755a
commit 2cd8bc74cc
2 changed files with 19 additions and 2 deletions

View File

@ -656,7 +656,8 @@ void SymbolDatabase::addFunction(SpaceInfo **info, const Token **tok, const Toke
{ {
// do the spaces match (same space) or do their names match (multiple namespaces) // do the spaces match (same space) or do their names match (multiple namespaces)
if ((*info == info1->nestedIn) || (*info && info1 && if ((*info == info1->nestedIn) || (*info && info1 &&
(*info)->className == info1->nestedIn->className && !(*info)->className.empty() && (*info)->className == info1->nestedIn->className &&
!(*info)->className.empty() &&
(*info)->type == info1->nestedIn->type)) (*info)->type == info1->nestedIn->type))
{ {
SpaceInfo *info2 = info1; SpaceInfo *info2 = info1;
@ -706,7 +707,7 @@ void SymbolDatabase::addFunction(SpaceInfo **info, const Token **tok, const Toke
func->arg = argStart; func->arg = argStart;
} }
} }
else if (func->tokenDef->str() == (*tok)->str()) else if (func->tokenDef->str() == (*tok)->str() && (*tok)->previous()->str() != "~")
{ {
if (argsMatch(func->tokenDef->next(), (*tok)->next(), path, path_length)) if (argsMatch(func->tokenDef->next(), (*tok)->next(), path, path_length))
{ {

View File

@ -58,6 +58,7 @@ private:
TEST_CASE(uninitVar12); // ticket #2078 TEST_CASE(uninitVar12); // ticket #2078
TEST_CASE(uninitVar13); // ticket #1195 TEST_CASE(uninitVar13); // ticket #1195
TEST_CASE(uninitVar14); // ticket #2149 TEST_CASE(uninitVar14); // ticket #2149
TEST_CASE(uninitVar15);
TEST_CASE(uninitVarEnum); TEST_CASE(uninitVarEnum);
TEST_CASE(uninitVarStream); TEST_CASE(uninitVarStream);
TEST_CASE(uninitVarTypedef); TEST_CASE(uninitVarTypedef);
@ -1936,6 +1937,21 @@ private:
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
} }
void uninitVar15()
{
checkUninitVar("class Fred\n"
"{\n"
" int a;\n"
"public:\n"
" Fred();\n"
" ~Fred();\n"
"};\n"
"Fred::~Fred()\n"
"{\n"
"}\n");
ASSERT_EQUALS("", errout.str());
}
void uninitVarArray1() void uninitVarArray1()
{ {
checkUninitVar("class John\n" checkUninitVar("class John\n"