diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index 8ce1e1be5..890e38975 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -486,6 +486,13 @@ SymbolDatabase::SymbolDatabase(const Tokenizer *tokenizer, const Settings *setti scope->functionList.push_back(function); } + // unknown macro (#5197) + else if (Token::Match(end, ") %any% ;")) { + tok = end->tokAt(3); + + scope->functionList.push_back(function); + } + // inline function else { function.isInline = true; diff --git a/test/testsymboldatabase.cpp b/test/testsymboldatabase.cpp index 75ec5cec6..a322beb16 100644 --- a/test/testsymboldatabase.cpp +++ b/test/testsymboldatabase.cpp @@ -202,6 +202,7 @@ private: TEST_CASE(symboldatabase38); // ticket #5125 (infinite recursion) TEST_CASE(symboldatabase39); // ticket #5120 (infinite recursion) TEST_CASE(symboldatabase40); // ticket #5153 + TEST_CASE(symboldatabase41); // ticket #5197 (unknown macro) TEST_CASE(isImplicitlyVirtual); @@ -1666,6 +1667,11 @@ private: ASSERT_EQUALS("", errout.str()); } + void symboldatabase41() { // ticket #5197 (unknown macro) + GET_SYMBOL_DB("struct X1 { MACRO1 f(int spd) MACRO2; };\n"); + ASSERT(db && db->findScopeByName("X1") && db->findScopeByName("X1")->functionList.size() == 1 && !db->findScopeByName("X1")->functionList.front().hasBody); + } + void isImplicitlyVirtual() { { GET_SYMBOL_DB("class Base {\n"