Fixed #2236 (False positive: Assignment to itself)
This commit is contained in:
parent
ea405d95c6
commit
00da0adf25
|
@ -4532,7 +4532,10 @@ void Tokenizer::simplifyCompoundAssignment()
|
|||
continue;
|
||||
|
||||
// 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;
|
||||
while (tok->next()->str() != ";")
|
||||
|
|
|
@ -4704,6 +4704,7 @@ private:
|
|||
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 *= 1;"));
|
||||
|
|
Loading…
Reference in New Issue