Fixed #2158 (False positive: value is not unused when using +=)
This commit is contained in:
parent
7e33b8fb9f
commit
3fb17baa12
|
@ -4369,7 +4369,7 @@ void Tokenizer::simplifyCompoundAssignment()
|
||||||
// "a+=b" => "a = a + b"
|
// "a+=b" => "a = a + b"
|
||||||
for (Token *tok = _tokens; tok; tok = tok->next())
|
for (Token *tok = _tokens; tok; tok = tok->next())
|
||||||
{
|
{
|
||||||
if (Token::Match(tok, "; %var%"))
|
if (Token::Match(tok, "[;{}] %var%"))
|
||||||
{
|
{
|
||||||
const Token * const vartok = tok->next();
|
const Token * const vartok = tok->next();
|
||||||
const std::string str = tok->strAt(2);
|
const std::string str = tok->strAt(2);
|
||||||
|
|
|
@ -4598,6 +4598,17 @@ private:
|
||||||
ASSERT_EQUALS("; x = x ^ y ;", tokenizeAndStringify("; x ^= y;"));
|
ASSERT_EQUALS("; x = x ^ y ;", tokenizeAndStringify("; x ^= y;"));
|
||||||
ASSERT_EQUALS("; x = x << y ;", tokenizeAndStringify("; x <<= y;"));
|
ASSERT_EQUALS("; x = x << y ;", tokenizeAndStringify("; x <<= y;"));
|
||||||
ASSERT_EQUALS("; x = x >> y ;", tokenizeAndStringify("; x >>= y;"));
|
ASSERT_EQUALS("; x = x >> y ;", tokenizeAndStringify("; x >>= y;"));
|
||||||
|
|
||||||
|
ASSERT_EQUALS("{ x = x + y ; }", tokenizeAndStringify("{ x += y;}"));
|
||||||
|
ASSERT_EQUALS("{ x = x - y ; }", tokenizeAndStringify("{ x -= y;}"));
|
||||||
|
ASSERT_EQUALS("{ x = x * y ; }", tokenizeAndStringify("{ x *= y;}"));
|
||||||
|
ASSERT_EQUALS("{ x = x / y ; }", tokenizeAndStringify("{ x /= y;}"));
|
||||||
|
ASSERT_EQUALS("{ x = x % y ; }", tokenizeAndStringify("{ x %= y;}"));
|
||||||
|
ASSERT_EQUALS("{ x = x & y ; }", tokenizeAndStringify("{ x &= y;}"));
|
||||||
|
ASSERT_EQUALS("{ x = x | y ; }", tokenizeAndStringify("{ x |= y;}"));
|
||||||
|
ASSERT_EQUALS("{ x = x ^ y ; }", tokenizeAndStringify("{ x ^= y;}"));
|
||||||
|
ASSERT_EQUALS("{ x = x << y ; }", tokenizeAndStringify("{ x <<= y;}"));
|
||||||
|
ASSERT_EQUALS("{ x = x >> y ; }", tokenizeAndStringify("{ x >>= y;}"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void simplifyAssignmentInFunctionCall()
|
void simplifyAssignmentInFunctionCall()
|
||||||
|
|
Loading…
Reference in New Issue