From 915cb6c757c954c948d317baabec0f44d3f72bf1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Wed, 25 Dec 2013 21:19:28 +0100 Subject: [PATCH] Fixed #5261 (AST: cast not handled well (a::b&)x) --- lib/tokenlist.cpp | 4 +--- test/testtokenize.cpp | 3 +++ 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/tokenlist.cpp b/lib/tokenlist.cpp index 3d80ebf9c..d07430400 100644 --- a/lib/tokenlist.cpp +++ b/lib/tokenlist.cpp @@ -363,7 +363,7 @@ static bool iscast(const Token *tok) return false; for (const Token *tok2 = tok->next(); tok2; tok2 = tok2->next()) { - if (!Token::Match(tok2, "%var%|*")) + if (!Token::Match(tok2, "%var%|*|&|::")) return Token::Match(tok2, ") %any%") && (!tok2->next()->isOp() && tok2->next()->str() != "["); } @@ -531,8 +531,6 @@ static void compileMulDiv(Token *&tok, std::stack &op) compileDot(tok,op); while (tok) { if (Token::Match(tok, "[*/%]")) { - if (Token::Match(tok, "* [,)]")) - break; compileBinOp(tok, compileDot, op); } else break; } diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 18dab17e5..7ccde8236 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -10033,6 +10033,9 @@ private: // casts ASSERT_EQUALS("a1(2(+=",testAst("a=(t)1+(t)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("a{+d+", testAst("a+({b+c;})+d"));