ast: fixed syntax tree for 'a=(b)?1:0'. The parentheses should not be in the syntax tree

This commit is contained in:
Daniel Marjamäki 2014-01-30 17:31:06 +01:00
parent ad0269eeeb
commit d6e3b3d3f3
2 changed files with 2 additions and 1 deletions

View File

@ -377,7 +377,7 @@ static bool iscast(const Token *tok)
for (const Token *tok2 = tok->next(); tok2; tok2 = tok2->next()) {
if (!Token::Match(tok2, "%var%|*|&|::"))
return Token::Match(tok2, ") %any%") && (!tok2->next()->isOp() && !Token::Match(tok2->next(), "[[]);,]"));
return Token::Match(tok2, ") %any%") && (!tok2->next()->isOp() && !Token::Match(tok2->next(), "[[]);,?:]"));
}
return false;

View File

@ -10152,6 +10152,7 @@ private:
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("ab1?0:=", testAst("a=(b)?1:0;"));
// ({..})
ASSERT_EQUALS("a{+d+ bc+", testAst("a+({b+c;})+d"));