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