varid: don't generate varid and symboldatabase variable for function call parameter

This commit is contained in:
Daniel Marjamäki 2016-12-18 20:16:38 +01:00
parent 17aaecbd6b
commit 4558701c08
4 changed files with 9 additions and 3 deletions

View File

@ -3249,7 +3249,7 @@ static const Token* skipScopeIdentifiers(const Token* tok)
static const Token* skipPointers(const Token* tok)
{
while (Token::Match(tok, "*|&|&&") || (tok && tok->str() == "(" && Token::Match(tok->link()->next(), "(|["))) {
while (Token::Match(tok, "*|&|&&") || (Token::Match(tok, "( [*&]") && Token::Match(tok->link()->next(), "(|["))) {
tok = tok->next();
if (tok->strAt(-1) == "(" && Token::Match(tok, "%type% ::"))
tok = tok->tokAt(2);

View File

@ -2320,7 +2320,7 @@ static bool setVarIdParseDeclaration(const Token **tok, const std::map<std::stri
singleNameCount = 1;
} else if (Token::Match(tok2, "&|&&")) {
ref = !bracket;
} else if (singleNameCount == 1 && tok2->str() == "(" && Token::Match(tok2->link()->next(), "(|[")) {
} else if (singleNameCount == 1 && Token::Match(tok2, "( [*&]") && Token::Match(tok2->link()->next(), "(|[")) {
bracket = true; // Skip: Seems to be valid pointer to array or function pointer
} else if (tok2->str() == "::") {
singleNameCount = 0;

View File

@ -1144,7 +1144,7 @@ private:
"void(*p2)(char); \n" // pointer to function (char) returning void
"int(*(*p3)(char))[10];\n" // pointer to function (char) returning pointer to array 10 of int
"float(*(*p4)(char))(long); \n" // pointer to function (char) returning pointer to function (long) returning float
"short(*(*(p5) (char))(long))(double); \n" // pointer to function (char) returning pointer to function (long) returning pointer to function (double) returning short
"short(*(*(*p5) (char))(long))(double);\n" // pointer to function (char) returning pointer to function (long) returning pointer to function (double) returning short
"int(*a1[10])(void); \n" // array 10 of pointer to function (void) returning int
"float(*(*a2[10])(char))(long);\n" // array 10 of pointer to func (char) returning pointer to func (long) returning float
"short(*(*(*a3[10])(char))(long))(double);\n" // array 10 of pointer to function (char) returning pointer to function (long) returning pointer to function (double) returning short

View File

@ -91,6 +91,7 @@ private:
TEST_CASE(varidFunctionCall2);
TEST_CASE(varidFunctionCall3);
TEST_CASE(varidFunctionCall4); // ticket #3280
TEST_CASE(varidFunctionCall5);
TEST_CASE(varidStl);
TEST_CASE(varid_newauto); // not declaration: new const auto(0);
TEST_CASE(varid_delete);
@ -1111,6 +1112,11 @@ private:
tokenize(code2, false, "test.c"));
}
void varidFunctionCall5() {
const char code[] = "void foo() { (f(x[2]))(x[2]); }";
ASSERT_EQUALS("1: void foo ( ) { f ( x [ 2 ] ) ( x [ 2 ] ) ; }\n",
tokenize(code, false, "test.c"));
}
void varidStl() {
const std::string actual = tokenize(