From e89f6d6ec05dc253fd736b19f8775c772228954e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sun, 27 Mar 2011 08:19:09 +0200 Subject: [PATCH] Fixed #2660 (False positive: Variable 'v' is assigned a value that is never used) --- lib/tokenize.cpp | 22 +++++++--------------- test/testtokenize.cpp | 1 + 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 34f0112be..1ec62857d 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -4974,25 +4974,17 @@ void Tokenizer::simplifyCompoundAssignment() // variable.. tok = tok->tokAt(2); while (Token::Match(tok, ". %var%") || - (tok && tok->str() == "[") || - Token::simpleMatch(tok, "( )")) + Token::Match(tok, "[|(")) { - if (tok->str() != "[") - tok = tok->tokAt(2); - else if (tok->str() == "(") + if (tok->str() == ".") tok = tok->tokAt(2); else { - // goto "]" - tok = tok->next(); - while (tok && !Token::Match(tok, "++|--|(|[|]")) - tok = tok->next(); - if (!tok) - break; - else if (tok->str() == "]") - tok = tok->next(); - else - break; + // goto "]" or ")" + tok = tok->link(); + + // goto next token.. + tok = tok ? tok->next() : 0; } } } diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 4a57c3dcc..07939f3dd 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -5523,6 +5523,7 @@ private: ASSERT_EQUALS(";", tokenizeAndStringify(";x /= 1;")); ASSERT_EQUALS("; a . x ( ) = a . x ( ) + 1 ;", tokenizeAndStringify("; a.x() += 1;")); + ASSERT_EQUALS("; x ( 1 ) = x ( 1 ) + 1 ;", tokenizeAndStringify("; x(1) += 1;")); // #2368 ASSERT_EQUALS("if ( false ) { } else { j = j - i ; }", tokenizeAndStringify("if (false) {} else { j -= i; }"));