Fixed #8796 (Tokenizer::simplifyCompoundAssignment: Wrong simplification of return)

This commit is contained in:
Daniel Marjamäki 2018-10-20 21:33:43 +02:00
parent ab985f624c
commit 14afc3fd3a
2 changed files with 5 additions and 0 deletions

View File

@ -4808,6 +4808,8 @@ void Tokenizer::simplifyCompoundAssignment()
for (Token *tok = list.front(); tok; tok = tok->next()) {
if (!Token::Match(tok, "[;{}] (| *| (| %name%"))
continue;
if (tok->next()->str() == "return")
continue;
// backup current token..
Token * const tok1 = tok;

View File

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