Fixed #5261 (AST: cast not handled well (a::b&)x)

This commit is contained in:
Daniel Marjamäki 2013-12-25 21:19:28 +01:00
parent aa65799c19
commit 915cb6c757
2 changed files with 4 additions and 3 deletions

View File

@ -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<Token*> &op)
compileDot(tok,op);
while (tok) {
if (Token::Match(tok, "[*/%]")) {
if (Token::Match(tok, "* [,)]"))
break;
compileBinOp(tok, compileDot, op);
} else break;
}

View File

@ -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"));