Skip to content

Commit

Permalink
Fix #12843 FP constParameterPointer (function pointer not set) (#6528)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrchr-github authored Jun 15, 2024
1 parent 1be5af7 commit 3c772a4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/symboldatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
8 changes: 8 additions & 0 deletions test/testother.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<void(*)(int*), int>&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() {
Expand Down

0 comments on commit 3c772a4

Please sign in to comment.