Fixed #11593 (function pointer => false negatives (ast? valueflow?))
This commit is contained in:
parent
17e776861e
commit
cfba046408
|
@ -1400,6 +1400,24 @@ static Token * findAstTop(Token *tok1, Token *tok2)
|
||||||
|
|
||||||
static Token * createAstAtToken(Token *tok, bool cpp)
|
static Token * createAstAtToken(Token *tok, bool cpp)
|
||||||
{
|
{
|
||||||
|
// skip function pointer declaration
|
||||||
|
if (Token::Match(tok, "%type%") && !Token::Match(tok, "return|throw|if|while")) {
|
||||||
|
const Token* type = tok;
|
||||||
|
while (Token::Match(type, "%type%|*|&|<")) {
|
||||||
|
if (type->str() == "<") {
|
||||||
|
if (type->link())
|
||||||
|
type = type->link();
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
type = type->next();
|
||||||
|
}
|
||||||
|
if (Token::simpleMatch(type, "(") &&
|
||||||
|
Token::Match(type->link()->previous(), "%var% ) (") &&
|
||||||
|
Token::Match(type->link()->linkAt(1), ") [;,)]"))
|
||||||
|
return type->link()->linkAt(1)->next();
|
||||||
|
}
|
||||||
|
|
||||||
if (Token::simpleMatch(tok, "for (")) {
|
if (Token::simpleMatch(tok, "for (")) {
|
||||||
if (cpp && Token::Match(tok, "for ( const| auto &|&&| [")) {
|
if (cpp && Token::Match(tok, "for ( const| auto &|&&| [")) {
|
||||||
Token *decl = Token::findsimplematch(tok, "[");
|
Token *decl = Token::findsimplematch(tok, "[");
|
||||||
|
|
|
@ -6270,6 +6270,9 @@ private:
|
||||||
|
|
||||||
ASSERT_EQUALS("vary=", testAst("std::string var = y;"));
|
ASSERT_EQUALS("vary=", testAst("std::string var = y;"));
|
||||||
|
|
||||||
|
ASSERT_EQUALS("", testAst("void *(*var)(int);"));
|
||||||
|
|
||||||
|
|
||||||
// create ast for decltype
|
// create ast for decltype
|
||||||
ASSERT_EQUALS("decltypex( var1=", testAst("decltype(x) var = 1;"));
|
ASSERT_EQUALS("decltypex( var1=", testAst("decltype(x) var = 1;"));
|
||||||
ASSERT_EQUALS("a1bdecltypet((>2,(", testAst("a(1 > b(decltype(t)), 2);")); // #10271
|
ASSERT_EQUALS("a1bdecltypet((>2,(", testAst("a(1 > b(decltype(t)), 2);")); // #10271
|
||||||
|
|
Loading…
Reference in New Issue