Set function pointer for ::f (#5028)
This commit is contained in:
parent
25183ff484
commit
7e0ddd3669
|
@ -1105,7 +1105,7 @@ void SymbolDatabase::createSymbolDatabaseSetFunctionPointers(bool firstPass)
|
|||
const Token *start = tok;
|
||||
while (Token::Match(start->tokAt(-2), "%name% ::"))
|
||||
start = start->tokAt(-2);
|
||||
if (!Token::Match(start->previous(), "[(,<=]") && !Token::Match(start->tokAt(-2), "[(,<=] &") && !Token::Match(start, "%name% ;"))
|
||||
if (!Token::Match(start->previous(), "[(,<=]") && !Token::simpleMatch(start->previous(), "::") && !Token::Match(start->tokAt(-2), "[(,<=] &") && !Token::Match(start, "%name% ;"))
|
||||
continue;
|
||||
isTemplateArg = Token::simpleMatch(start->previous(), "<") || Token::simpleMatch(start->tokAt(-2), "<");
|
||||
}
|
||||
|
@ -5577,8 +5577,8 @@ const Function* SymbolDatabase::findFunction(const Token* const tok) const
|
|||
if (tok1->strAt(-1) == "::") {
|
||||
currScope = &scopeList.front();
|
||||
|
||||
if (Token::Match(tok1, "%name% ("))
|
||||
return currScope->findFunction(tok);
|
||||
if (const Function* f = currScope->findFunction(tok))
|
||||
return f;
|
||||
|
||||
currScope = currScope->findRecordInNestedList(tok1->str());
|
||||
}
|
||||
|
|
|
@ -3522,6 +3522,18 @@ private:
|
|||
ASSERT_EQUALS("[test.cpp:7] -> [test.cpp:2]: (style) Parameter 'p' can be declared as pointer to const. "
|
||||
"However it seems that 'cb' is a callback function, if 'p' is declared with const you might also need to cast function pointer(s).\n",
|
||||
errout.str());
|
||||
|
||||
check("typedef void (*cb_t)(int*);\n"
|
||||
"void cb(int* p) {\n"
|
||||
" if (*p) {}\n"
|
||||
"}\n"
|
||||
"void g(cb_t);\n"
|
||||
"void f() {\n"
|
||||
" g(::cb);\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("[test.cpp:7] -> [test.cpp:2]: (style) Parameter 'p' can be declared as pointer to const. "
|
||||
"However it seems that 'cb' is a callback function, if 'p' is declared with const you might also need to cast function pointer(s).\n",
|
||||
errout.str());
|
||||
}
|
||||
|
||||
void switchRedundantAssignmentTest() {
|
||||
|
|
Loading…
Reference in New Issue