From e4937ed621242fcd45fd06091c168378a1f598fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Tue, 25 Feb 2020 21:05:36 +0100 Subject: [PATCH] AST: Fixed wrong AST for cast '(std::vector&&)s->second' --- lib/tokenlist.cpp | 8 +++++--- test/testtokenize.cpp | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/tokenlist.cpp b/lib/tokenlist.cpp index 335f4ecb4..69cd2a31e 100644 --- a/lib/tokenlist.cpp +++ b/lib/tokenlist.cpp @@ -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(), "( * *| )"))) diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 27e90def0..f55b6cc77 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -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