diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index 48a102ae7..d57eac848 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -1459,7 +1459,7 @@ bool SymbolDatabase::isFunction(const Token *tok, const Scope* outerScope, const } // skip over modifiers and other stuff - while (Token::Match(tok1, "const|static|extern|template|virtual|struct|class|enum")) + while (Token::Match(tok1, "const|static|extern|template|virtual|struct|class|enum|%name%")) tok1 = tok1->previous(); // should be at a sequence point if this is a function diff --git a/test/testsymboldatabase.cpp b/test/testsymboldatabase.cpp index 5d34d360d..2c9f550d4 100644 --- a/test/testsymboldatabase.cpp +++ b/test/testsymboldatabase.cpp @@ -253,6 +253,7 @@ private: TEST_CASE(symboldatabase52); // #6581 TEST_CASE(symboldatabase53); // #7124 (library podtype) TEST_CASE(symboldatabase54); // #7257 + TEST_CASE(symboldatabase55); // #7767 (return unknown macro) TEST_CASE(enum1); TEST_CASE(enum2); @@ -2652,6 +2653,18 @@ private: } } + void symboldatabase55() { // #7767 + GET_SYMBOL_DB("PRIVATE S32 testfunc(void) {\n" + " return 0;\n" + "}"); + + ASSERT(db != nullptr); + if (db) { + ASSERT_EQUALS(1U, db->functionScopes.size()); + ASSERT_EQUALS("testfunc", db->functionScopes.front()->className); + } + } + void enum1() { GET_SYMBOL_DB("enum BOOL { FALSE, TRUE }; enum BOOL b;");