Tokenizer::varId: don't set varid for function name in code 'bool f(X x, int=3);'

This commit is contained in:
Daniel Marjamäki 2014-10-14 20:37:32 +02:00
parent 82972b7b0d
commit 36297f1025
2 changed files with 13 additions and 0 deletions

View File

@ -2327,6 +2327,12 @@ static bool setVarIdParseDeclaration(const Token **tok, const std::map<std::stri
return false; return false;
} }
if (typeCount >= 2 && tok2 && tok2->str() == "(") {
const Token *tok3 = tok2->next();
if (tok3->str() != "new" && tok3->str() != "sizeof" && setVarIdParseDeclaration(&tok3, variableId, executableScope, cpp))
return false;
}
return bool(typeCount >= 2 && tok2 && Token::Match(tok2->tokAt(-2), "!!:: %type%")); return bool(typeCount >= 2 && tok2 && Token::Match(tok2->tokAt(-2), "!!:: %type%"));
} }

View File

@ -1171,6 +1171,13 @@ private:
"1: void f ( struct foobar ) ;\n"); "1: void f ( struct foobar ) ;\n");
ASSERT_EQUALS(expected, actual); ASSERT_EQUALS(expected, actual);
} }
{
const std::string actual = tokenize("bool f(X x, int=3);", false, "test.cpp");
const std::string expected("\n\n##file 0\n"
"1: bool f ( X x@1 , int = 3 ) ;\n");
ASSERT_EQUALS(expected, actual);
}
} }
void varid_sizeof() { void varid_sizeof() {