AST: Fixed wrong AST for cast '(std::vector<int>&&)s->second'

This commit is contained in:
Daniel Marjamäki 2020-02-25 21:05:36 +01:00
parent e9937e3acb
commit e4937ed621
2 changed files with 6 additions and 3 deletions

View File

@ -526,8 +526,6 @@ static bool iscast(const Token *tok)
tok2 = tok2->link()->next();
if (tok2->str() == ")") {
if (Token::Match(tok2->previous(), "&|&& )"))
return true;
if (Token::simpleMatch(tok2, ") (") && Token::simpleMatch(tok2->linkAt(1), ") ."))
return true;
return type || tok2->strAt(-1) == "*" || Token::simpleMatch(tok2, ") ~") ||
@ -535,7 +533,11 @@ static bool iscast(const Token *tok)
!tok2->next()->isOp() &&
!Token::Match(tok2->next(), "[[]);,?:.]"));
}
if (!Token::Match(tok2, "%name%|*|&|::"))
if (Token::Match(tok2, "&|&& )"))
return true;
if (!Token::Match(tok2, "%name%|*|::"))
return false;
if (tok2->isStandardType() && (tok2->next()->str() != "(" || Token::Match(tok2->next(), "( * *| )")))

View File

@ -7658,6 +7658,7 @@ private:
ASSERT_EQUALS("a1(2+=",testAst("a=(t)1+2;"));
ASSERT_EQUALS("a1(2+=",testAst("a=(t*)1+2;"));
ASSERT_EQUALS("a1(2+=",testAst("a=(t&)1+2;"));
ASSERT_EQUALS("a1(2+=",testAst("a=(t&&)1+2;"));
ASSERT_EQUALS("ab::r&c(=", testAst("a::b& r = (a::b&)c;")); // #5261
ASSERT_EQUALS("ab10:?=", testAst("a=(b)?1:0;"));
ASSERT_EQUALS("ac5[new(=", testAst("a = (b*)(new c[5]);")); // #8786