Fixed #2236 (False positive: Assignment to itself)

This commit is contained in:
Daniel Marjamäki 2010-11-28 11:48:06 +01:00
parent ea405d95c6
commit 00da0adf25
2 changed files with 5 additions and 1 deletions

View File

@ -4532,7 +4532,10 @@ void Tokenizer::simplifyCompoundAssignment()
continue; continue;
// Remove the whole statement if it says: "+=0;", "-=0;", "*=1;" or "/=1;" // Remove the whole statement if it says: "+=0;", "-=0;", "*=1;" or "/=1;"
if (Token::Match(tok, "+=|-= 0 ;") || Token::simpleMatch(tok, "|= 0 ;") || Token::Match(tok, "*=|/= 1 ;")) if (Token::Match(tok, "+=|-= 0 ;") ||
Token::Match(tok, "+=|-= '\\0' ;") ||
Token::simpleMatch(tok, "|= 0 ;") ||
Token::Match(tok, "*=|/= 1 ;"))
{ {
tok = tok1; tok = tok1;
while (tok->next()->str() != ";") while (tok->next()->str() != ";")

View File

@ -4704,6 +4704,7 @@ private:
ASSERT_EQUALS("; x [ y - 1 ] = x [ y - 1 ] + 1 ;", tokenizeAndStringify("; x[y-1] += 1;")); ASSERT_EQUALS("; x [ y - 1 ] = x [ y - 1 ] + 1 ;", tokenizeAndStringify("; x[y-1] += 1;"));
ASSERT_EQUALS(";", tokenizeAndStringify(";x += 0;")); ASSERT_EQUALS(";", tokenizeAndStringify(";x += 0;"));
ASSERT_EQUALS(";", tokenizeAndStringify(";x += '\\0';"));
ASSERT_EQUALS(";", tokenizeAndStringify(";x -= 0;")); ASSERT_EQUALS(";", tokenizeAndStringify(";x -= 0;"));
ASSERT_EQUALS(";", tokenizeAndStringify(";x |= 0;")); ASSERT_EQUALS(";", tokenizeAndStringify(";x |= 0;"));
ASSERT_EQUALS(";", tokenizeAndStringify(";x *= 1;")); ASSERT_EQUALS(";", tokenizeAndStringify(";x *= 1;"));