Support lambdas in simplifyCompoundAssignment (#7571)

This commit is contained in:
PKEuS 2016-07-08 20:10:33 +02:00
parent 87372ccd58
commit a808549af0
3 changed files with 6 additions and 3 deletions

View File

@ -4659,7 +4659,7 @@ void Tokenizer::simplifyCompoundAssignment()
// Only enclose rhs in parentheses if there is some operator
bool someOperator = false;
for (Token *tok2 = tok->next(); tok2; tok2 = tok2->next()) {
if (tok2->str() == "(")
if (tok2->link() && Token::Match(tok2, "{|[|("))
tok2 = tok2->link();
if (Token::Match(tok2->next(), "[;)]")) {

View File

@ -362,6 +362,9 @@ private:
// #3469
ASSERT_EQUALS("; a = a + ( b = 1 ) ;", tok("; a += b = 1;"));
// #7571
ASSERT_EQUALS("; foo = foo + [ & ] ( ) { } ;", tok("; foo += [&]() {int i;};"));
}