Fixed #10376 (Cppcheck does not add some function arguments to the dump file)

This commit is contained in:
Daniel Marjamäki 2021-08-15 07:48:01 +02:00
parent b3034a5628
commit 83270a6c52
2 changed files with 14 additions and 0 deletions

View File

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

View File

@ -245,6 +245,7 @@ private:
TEST_CASE(functionArgs15); // #7159
TEST_CASE(functionArgs16); // #9591
TEST_CASE(functionArgs17);
TEST_CASE(functionArgs18); // #10376
TEST_CASE(functionImplicitlyVirtual);
@ -2490,6 +2491,15 @@ private:
ASSERT_EQUALS(3, func->argCount());
}
void functionArgs18() {
const char code[] = "void f(int (*param1)[2], int param2) {}";
GET_SYMBOL_DB(code);
ASSERT(db != nullptr);
const Scope *scope = db->functionScopes.front();
const Function *func = scope->function;
ASSERT_EQUALS(2, func->argCount());
}
void functionImplicitlyVirtual() {
GET_SYMBOL_DB("class base { virtual void f(); };\n"
"class derived : base { void f(); };\n"