From 54e0b60cc58ea491925629d3ceecc425ec7684a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Wed, 16 Feb 2011 20:33:24 +0100 Subject: [PATCH] Fixed #2584 (false positive 'variable n is never used') --- lib/tokenize.cpp | 2 +- test/testtokenize.cpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index be64337b5..90287bb39 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -4712,7 +4712,7 @@ void Tokenizer::simplifyCompoundAssignment() // "a+=b" => "a = a + b" for (Token *tok = _tokens; tok; tok = tok->next()) { - if (Token::Match(tok, "[;{}:] *| (| %var%")) + if (Token::Match(tok, "[;{}] (") || Token::Match(tok, "[;{}:] *| (| %var%")) { if (tok->str() == ":") { diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 76b3b7a40..978ec46d7 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -5196,6 +5196,7 @@ private: ASSERT_EQUALS("{ x = x >> y ; }", tokenizeAndStringify("{ x >>= y;}")); ASSERT_EQUALS("; * p = * p + y ;", tokenizeAndStringify("; *p += y;")); + ASSERT_EQUALS("; ( * p ) = ( * p ) + y ;", tokenizeAndStringify("; (*p) += y;")); ASSERT_EQUALS("; * ( p [ 0 ] ) = * ( p [ 0 ] ) + y ;", tokenizeAndStringify("; *(p[0]) += y;")); ASSERT_EQUALS("case 0 : x = x + y ; break ;", tokenizeAndStringify("case 0: x += y; break;"));