Skip to content

Commit 3c772a4

Browse files
Fix #12843 FP constParameterPointer (function pointer not set) (#6528)
1 parent 1be5af7 commit 3c772a4

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

lib/symboldatabase.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1152,7 +1152,7 @@ void SymbolDatabase::createSymbolDatabaseSetFunctionPointers(bool firstPass)
11521152
inTemplateArg = tok->link();
11531153
if (inTemplateArg == tok)
11541154
inTemplateArg = nullptr;
1155-
if (tok->isName() && !tok->function() && tok->varId() == 0 && ((tok->astParent() && tok->astParent()->isComparisonOp()) || Token::Match(tok, "%name% [{(,)>;]")) && !isReservedName(tok)) {
1155+
if (tok->isName() && !tok->function() && tok->varId() == 0 && ((tok->astParent() && tok->astParent()->isComparisonOp()) || Token::Match(tok, "%name% [{(,)>;]]")) && !isReservedName(tok)) {
11561156
if (tok->strAt(1) == ">" && !tok->linkAt(1))
11571157
continue;
11581158

test/testother.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3647,6 +3647,14 @@ class TestOther : public TestFixture {
36473647
" switch (signal.signum) {}\n"
36483648
"}");
36493649
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());
3650+
3651+
check("void f(int* p) {}\n" // 12843
3652+
"void g(std::map<void(*)(int*), int>&m) {\n"
3653+
" m[&f] = 0;\n"
3654+
"}");
3655+
ASSERT_EQUALS("[test.cpp:3] -> [test.cpp:1]: (style) Parameter 'p' can be declared as pointer to const. "
3656+
"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",
3657+
errout_str());
36503658
}
36513659

36523660
void constPointer() {

0 commit comments

Comments
 (0)