Fixed #7767 (SymbolDatabase: function not analysed when unknown macros are in front of function definition)

This commit is contained in:
Robert Reif 2016-10-22 22:29:18 +02:00 committed by Daniel Marjamäki
parent 8a0f3009ff
commit f25d205999
2 changed files with 14 additions and 1 deletions

View File

@ -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

View File

@ -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;");