diff --git a/lib/token.cpp b/lib/token.cpp index 22840878f..95ce9b0e3 100644 --- a/lib/token.cpp +++ b/lib/token.cpp @@ -142,7 +142,7 @@ void Token::replace(Token *replaceThis, Token *start, Token *end) start->previous(replaceThis->previous()); end->next(replaceThis->next()); - if (end->tokensBack && *(end->tokensBack) == replaceThis) + if (end->tokensBack && *(end->tokensBack) == end) { while (end->next()) end = end->next(); diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 35e091977..cc4a08ebf 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -5126,13 +5126,11 @@ bool Tokenizer::validate() const return false; } + // Validate that the Tokenizer::_tokensBack is updated correctly during simplifications if (lastTok != _tokensBack) { - // TODO, the two lines below should be uncommented and - // problems that appear with testrunner should be fixed - - //cppcheckError(lastTok); - //return false; + cppcheckError(lastTok); + return false; } return true;