SymbolDatabase: Better handling of function pointer function argument

This commit is contained in:
Daniel Marjamäki 2020-05-02 17:04:54 +02:00
parent 90108002e5
commit 5eeeba97eb
2 changed files with 14 additions and 0 deletions

View File

@ -3500,6 +3500,10 @@ void Function::addArguments(const SymbolDatabase *symbolDatabase, const Scope *s
nameTok = tok->tokAt(2);
endTok = nameTok->previous();
tok = tok->link();
} else if (tok != startTok && !nameTok && Token::Match(tok, "( * %var% ) ( ) [,)]")) {
nameTok = tok->tokAt(2);
endTok = nameTok->previous();
tok = tok->link()->tokAt(2);
} else if (tok->varId() != 0) {
nameTok = tok;
endTok = tok->previous();

View File

@ -228,6 +228,7 @@ private:
TEST_CASE(functionArgs14); // #9055
TEST_CASE(functionArgs15); // #7159
TEST_CASE(functionArgs16); // #9591
TEST_CASE(functionArgs17);
TEST_CASE(functionImplicitlyVirtual);
@ -2386,6 +2387,15 @@ private:
ASSERT(arg2->isReference());
}
void functionArgs17() {
const char code[] = "void f(int (*fp)(), int x, int y) {}";
GET_SYMBOL_DB(code);
ASSERT(db != nullptr);
const Scope *scope = db->functionScopes.front();
const Function *func = scope->function;
ASSERT_EQUALS(3, func->argCount());
}
void functionImplicitlyVirtual() {
GET_SYMBOL_DB("class base { virtual void f(); };\n"
"class derived : base { void f(); };\n"