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;
|
const Token *start = tok;
|
||||||
while (Token::Match(start->tokAt(-2), "%name% ::"))
|
while (Token::Match(start->tokAt(-2), "%name% ::"))
|
||||||
start = start->tokAt(-2);
|
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;
|
continue;
|
||||||
isTemplateArg = Token::simpleMatch(start->previous(), "<") || Token::simpleMatch(start->tokAt(-2), "<");
|
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) == "::") {
|
if (tok1->strAt(-1) == "::") {
|
||||||
currScope = &scopeList.front();
|
currScope = &scopeList.front();
|
||||||
|
|
||||||
if (Token::Match(tok1, "%name% ("))
|
if (const Function* f = currScope->findFunction(tok))
|
||||||
return currScope->findFunction(tok);
|
return f;
|
||||||
|
|
||||||
currScope = currScope->findRecordInNestedList(tok1->str());
|
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. "
|
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",
|
"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());
|
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() {
|
void switchRedundantAssignmentTest() {
|
||||||
|
|
Loading…
Reference in New Issue