diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index 831a7399313..1ee239a9e74 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -1152,7 +1152,7 @@ void SymbolDatabase::createSymbolDatabaseSetFunctionPointers(bool firstPass) inTemplateArg = tok->link(); if (inTemplateArg == tok) inTemplateArg = nullptr; - if (tok->isName() && !tok->function() && tok->varId() == 0 && ((tok->astParent() && tok->astParent()->isComparisonOp()) || Token::Match(tok, "%name% [{(,)>;]")) && !isReservedName(tok)) { + if (tok->isName() && !tok->function() && tok->varId() == 0 && ((tok->astParent() && tok->astParent()->isComparisonOp()) || Token::Match(tok, "%name% [{(,)>;]]")) && !isReservedName(tok)) { if (tok->strAt(1) == ">" && !tok->linkAt(1)) continue; diff --git a/test/testother.cpp b/test/testother.cpp index 75cec25b539..d71fd173d63 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -3647,6 +3647,14 @@ class TestOther : public TestFixture { " switch (signal.signum) {}\n" "}"); ASSERT_EQUALS("[test.cpp:10] -> [test.cpp:13]: (style) Parameter 'signal' can be declared as reference to const. However it seems that 'signalEvent' is a callback function, if 'signal' is declared with const you might also need to cast function pointer(s).\n", errout_str()); + + check("void f(int* p) {}\n" // 12843 + "void g(std::map&m) {\n" + " m[&f] = 0;\n" + "}"); + ASSERT_EQUALS("[test.cpp:3] -> [test.cpp:1]: (style) Parameter 'p' can be declared as pointer to const. " + "However it seems that 'f' is a callback function, if 'p' is declared with const you might also need to cast function pointer(s).\n", + errout_str()); } void constPointer() {