ast: fixed trouble with 'ab=a+(b/(c))+d;' where the '(c)' could be mistaken for a cast

This commit is contained in:
Daniel Marjamäki 2014-01-08 21:49:42 +01:00
parent 4f11086505
commit 04cb56e070
2 changed files with 4 additions and 1 deletions

View File

@ -370,7 +370,7 @@ static bool iscast(const Token *tok)
for (const Token *tok2 = tok->next(); tok2; tok2 = tok2->next()) { 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() != "["); return Token::Match(tok2, ") %any%") && (!tok2->next()->isOp() && !Token::Match(tok2->next(), "[[])]"));
} }
return false; return false;

View File

@ -10074,6 +10074,9 @@ private:
ASSERT_EQUALS("'X''a'>", testAst("('X' > 'a')")); ASSERT_EQUALS("'X''a'>", testAst("('X' > 'a')"));
ASSERT_EQUALS("'X''a'>", testAst("(L'X' > L'a')")); ASSERT_EQUALS("'X''a'>", testAst("(L'X' > L'a')"));
ASSERT_EQUALS("a0>bc/?d:", testAst("(a>0) ? (b/(c)) : d;"));
ASSERT_EQUALS("abc/+d+", testAst("a + (b/(c)) + d;"));
} }
void astpar() const { // parentheses void astpar() const { // parentheses