This commit is contained in:
parent
6376bac5bb
commit
200b098471
|
@ -1177,7 +1177,7 @@ static bool checkFunctionUsage(const Function *privfunc, const Scope* scope)
|
||||||
|
|
||||||
for (const Variable &var : scope->varlist) {
|
for (const Variable &var : scope->varlist) {
|
||||||
if (var.isStatic()) {
|
if (var.isStatic()) {
|
||||||
const Token* tok = Token::findmatch(scope->bodyEnd, "%varid% =|(|{", var.declarationId());
|
const Token* tok = Token::findmatch(scope->bodyStart, "%varid% =|(|{", var.declarationId());
|
||||||
if (tok)
|
if (tok)
|
||||||
tok = tok->tokAt(2);
|
tok = tok->tokAt(2);
|
||||||
while (tok && tok->str() != ";") {
|
while (tok && tok->str() != ";") {
|
||||||
|
|
|
@ -1081,7 +1081,7 @@ void SymbolDatabase::createSymbolDatabaseSetFunctionPointers(bool firstPass)
|
||||||
|
|
||||||
// Set function call pointers
|
// Set function call pointers
|
||||||
for (const Token* tok = mTokenizer->list.front(); tok != mTokenizer->list.back(); tok = tok->next()) {
|
for (const Token* tok = mTokenizer->list.front(); tok != mTokenizer->list.back(); tok = tok->next()) {
|
||||||
if (tok->isName() && !tok->function() && tok->varId() == 0 && Token::Match(tok, "%name% [(,)>]") && !isReservedName(tok->str())) {
|
if (tok->isName() && !tok->function() && tok->varId() == 0 && Token::Match(tok, "%name% [(,)>;]") && !isReservedName(tok->str())) {
|
||||||
if (tok->next()->str() == ">" && !tok->next()->link())
|
if (tok->next()->str() == ">" && !tok->next()->link())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -1089,7 +1089,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), "[(,<] &"))
|
if (!Token::Match(start->previous(), "[(,<=]") && !Token::Match(start->tokAt(-2), "[(,<=] &") && !Token::Match(start, "%name% ;"))
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5352,8 +5352,13 @@ const Function* SymbolDatabase::findFunction(const Token *tok) const
|
||||||
else
|
else
|
||||||
tok1 = nullptr;
|
tok1 = nullptr;
|
||||||
|
|
||||||
if (tok1)
|
if (tok1) {
|
||||||
|
const Function* func = currScope->findFunction(tok1);
|
||||||
|
if (func)
|
||||||
|
return func;
|
||||||
|
|
||||||
currScope = currScope->findRecordInNestedList(tok1->str());
|
currScope = currScope->findRecordInNestedList(tok1->str());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tok1)
|
if (tok1)
|
||||||
|
|
|
@ -55,6 +55,7 @@ private:
|
||||||
TEST_CASE(func_pointer4); // ticket #2807
|
TEST_CASE(func_pointer4); // ticket #2807
|
||||||
TEST_CASE(func_pointer5); // ticket #2233
|
TEST_CASE(func_pointer5); // ticket #2233
|
||||||
TEST_CASE(func_pointer6); // ticket #4787
|
TEST_CASE(func_pointer6); // ticket #4787
|
||||||
|
TEST_CASE(func_pointer7); // ticket #10516
|
||||||
|
|
||||||
TEST_CASE(ctor);
|
TEST_CASE(ctor);
|
||||||
TEST_CASE(ctor2);
|
TEST_CASE(ctor2);
|
||||||
|
@ -349,6 +350,32 @@ private:
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void func_pointer7() { // #10516
|
||||||
|
check("class C {\n"
|
||||||
|
" static void f() {}\n"
|
||||||
|
" static constexpr void(*p)() = f;\n"
|
||||||
|
"};\n");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
check("class C {\n"
|
||||||
|
" static void f() {}\n"
|
||||||
|
" static constexpr void(*p)() = &f;\n"
|
||||||
|
"};\n");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
check("class C {\n"
|
||||||
|
" static void f() {}\n"
|
||||||
|
" static constexpr void(*p)() = C::f;\n"
|
||||||
|
"};\n");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
check("class C {\n"
|
||||||
|
" static void f() {}\n"
|
||||||
|
" static constexpr void(*p)() = &C::f;\n"
|
||||||
|
"};\n");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void ctor() {
|
void ctor() {
|
||||||
check("class PrivateCtor\n"
|
check("class PrivateCtor\n"
|
||||||
|
|
Loading…
Reference in New Issue