Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/symboldatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1581,7 +1581,7 @@ bool SymbolDatabase::isFunction(const Token *tok, const Scope* outerScope, const
}

// should be at a sequence point if this is a function
if (!Token::Match(tok1, ">|{|}|;|public:|protected:|private:") && tok1)
if (!Token::Match(tok1, ">|{|}|;|)|public:|protected:|private:") && tok1)
return false;
}

Expand Down
39 changes: 39 additions & 0 deletions test/testsymboldatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,9 @@ class TestSymbolDatabase: public TestFixture {
TEST_CASE(auto7);
TEST_CASE(auto8);
TEST_CASE(auto9); // #8044 (segmentation fault)

TEST_CASE(macroFuncionTest1);
TEST_CASE(macroFuncionTest2);
}

void array() {
Expand Down Expand Up @@ -5185,6 +5188,42 @@ class TestSymbolDatabase: public TestFixture {
ASSERT_EQUALS(true, db != nullptr); // not null
}

void macroFuncionTest1() {
GET_SYMBOL_DB("class MacroTest\n {"
"public:\n"
" SOME_MACRO_WITH_NO_SEMICOLON()\n"
" void Init() { }\n"
"};\n");

// 3 scopes: Global, Class, and Function
ASSERT(db && db->scopeList.size() == 3);

if (!db)
return;

const Scope *scope = db->findScopeByName("MacroTest");
ASSERT(scope && scope->functionList.size() == 1);
ASSERT(findFunctionByName("Init", scope) != NULL);
}

void macroFuncionTest2() {
GET_SYMBOL_DB("class MacroTest\n {"
"public:\n"
" SOME_MACRO_WITH_NO_SEMICOLON(1, 2, 3)\n"
" void Init() { }\n"
"};\n");

// 3 scopes: Global, Class, and Function
ASSERT(db && db->scopeList.size() == 3);

if (!db)
return;

const Scope *scope = db->findScopeByName("MacroTest");
ASSERT(scope && scope->functionList.size() == 1);
ASSERT(findFunctionByName("Init", scope) != NULL);
}

};

REGISTER_TEST(TestSymbolDatabase)