diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index 128e7f5e9..7498285ad 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -1103,7 +1103,7 @@ void SymbolDatabase::createSymbolDatabaseSetFunctionPointers(bool firstPass) // Set function call pointers for (const Token* tok = mTokenizer.list.front(); tok != mTokenizer.list.back(); tok = tok->next()) { - if (tok->isName() && !tok->function() && tok->varId() == 0 && Token::Match(tok, "%name% [{(,)>;]") && !isReservedName(tok->str())) { + if (tok->isName() && !tok->function() && tok->varId() == 0 && ((tok->astParent() && tok->astParent()->isComparisonOp()) || Token::Match(tok, "%name% [{(,)>;]")) && !isReservedName(tok->str())) { if (tok->next()->str() == ">" && !tok->next()->link()) continue; diff --git a/test/testsymboldatabase.cpp b/test/testsymboldatabase.cpp index e7d2e45e2..b7e846784 100644 --- a/test/testsymboldatabase.cpp +++ b/test/testsymboldatabase.cpp @@ -450,6 +450,7 @@ private: TEST_CASE(findFunction49); // #11888 TEST_CASE(findFunction50); // #11904 - method with same name and arguments in derived class TEST_CASE(findFunction51); // #11975 - method with same name in derived class + TEST_CASE(findFunction52); TEST_CASE(findFunctionContainer); TEST_CASE(findFunctionExternC); TEST_CASE(findFunctionGlobalScope); // ::foo @@ -7558,6 +7559,16 @@ private: } } + void findFunction52() { + GET_SYMBOL_DB("int g();\n" + "void f() {\n" + " if (g != 0) {}\n" + "}\n"); + const Token* g = Token::findsimplematch(tokenizer.tokens(), "g !="); + ASSERT(g->function() && g->function()->tokenDef); + ASSERT(g->function()->tokenDef->linenr() == 1); + } + void findFunctionContainer() { { GET_SYMBOL_DB("void dostuff(std::vector v);\n"