Skip to content
Merged
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
3 changes: 3 additions & 0 deletions lib/symboldatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5984,6 +5984,9 @@ const Function* Scope::findFunction(const Token *tok, bool requireConst, Referen

const Function* SymbolDatabase::findFunction(const Token* const tok) const
{
if (tok->tokType() == Token::Type::eEnumerator)
return nullptr;

// find the scope this function is in
const Scope *currScope = tok->scope();
while (currScope && currScope->isExecutable()) {
Expand Down
14 changes: 14 additions & 0 deletions test/testsymboldatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,7 @@ class TestSymbolDatabase : public TestFixture {
TEST_CASE(findFunction55); // #13004
TEST_CASE(findFunction56);
TEST_CASE(findFunction57);
TEST_CASE(findFunction58); // #13310
TEST_CASE(findFunctionRef1);
TEST_CASE(findFunctionContainer);
TEST_CASE(findFunctionExternC);
Expand Down Expand Up @@ -8374,6 +8375,19 @@ class TestSymbolDatabase : public TestFixture {
ASSERT_EQUALS(T->function()->tokenDef->linenr(), 6);
}

void findFunction58() { // #13310
GET_SYMBOL_DB("class C {\n"
" enum class abc : uint8_t {\n"
" a,b,c\n"
" };\n"
" void a();\n"
"};\n");
const Token *a1 = Token::findsimplematch(tokenizer.tokens(), "a ,");
ASSERT(a1 && !a1->function());
const Token *a2 = Token::findsimplematch(tokenizer.tokens(), "a (");
ASSERT(a2 && a2->function());
}

void findFunctionRef1() {
GET_SYMBOL_DB("struct X {\n"
" const std::vector<int> getInts() const & { return mInts; }\n"
Expand Down