diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index 52f601c4e..97cbf6a15 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -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) 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)) { SpaceInfo *info2 = info1; @@ -706,7 +707,7 @@ void SymbolDatabase::addFunction(SpaceInfo **info, const Token **tok, const Toke 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)) { diff --git a/test/testclass.cpp b/test/testclass.cpp index e1e52f94e..b868feb27 100644 --- a/test/testclass.cpp +++ b/test/testclass.cpp @@ -58,6 +58,7 @@ private: TEST_CASE(uninitVar12); // ticket #2078 TEST_CASE(uninitVar13); // ticket #1195 TEST_CASE(uninitVar14); // ticket #2149 + TEST_CASE(uninitVar15); TEST_CASE(uninitVarEnum); TEST_CASE(uninitVarStream); TEST_CASE(uninitVarTypedef); @@ -1936,6 +1937,21 @@ private: 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() { checkUninitVar("class John\n"