SymbolDatabase: Do not set constructor flag for function in namespace

This commit is contained in:
Daniel Marjamäki 2019-10-20 18:12:52 +02:00
parent 82d8f3e7f5
commit 223ceeb97f
2 changed files with 8 additions and 1 deletions

View File

@ -1892,7 +1892,7 @@ Function::Function(const Tokenizer *mTokenizer,
}
// class constructor/destructor
else if (tokenDef->str() == scope->className) {
else if (tokenDef->str() == scope->className && scope->type != Scope::ScopeType::eNamespace) {
// destructor
if (tokenDef->previous()->str() == "~")
type = Function::eDestructor;

View File

@ -304,6 +304,7 @@ private:
TEST_CASE(symboldatabase79); // #9392
TEST_CASE(symboldatabase80); // #9389
TEST_CASE(symboldatabase81); // #9411
TEST_CASE(symboldatabase82);
TEST_CASE(createSymbolDatabaseFindAllScopes1);
@ -4406,6 +4407,12 @@ private:
}
}
void symboldatabase82() {
GET_SYMBOL_DB("namespace foo { void foo() {} }");
ASSERT(db->functionScopes.size() == 1);
ASSERT_EQUALS(false, db->functionScopes[0]->function->isConstructor());
}
void createSymbolDatabaseFindAllScopes1() {
GET_SYMBOL_DB("void f() { union {int x; char *p;} a={0}; }");
ASSERT(db->scopeList.size() == 3);