From 5fb2115e9daff7cae437167d6397fd6c0435bbb1 Mon Sep 17 00:00:00 2001 From: Edoardo Prezioso Date: Tue, 20 Nov 2012 19:12:22 +0100 Subject: [PATCH] Fixed a bug in Tokenizer::concatenateNegativeNumber. The first negative number inside a '{}' list was not simplified correctly. --- 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 3140dbc65..4e7f73827 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -2148,7 +2148,7 @@ void Tokenizer::simplifyNull() void Tokenizer::concatenateNegativeNumber() { for (Token *tok = list.front(); tok; tok = tok->next()) { - if (Token::Match(tok, "?|:|,|(|[|=|return|case|sizeof|%op% - %num%")) { + if (Token::Match(tok, "?|:|,|(|[|{|=|return|case|sizeof|%op% - %num%")) { tok->deleteNext(); tok->next()->str("-" + tok->next()->str()); } diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 1440c1d26..aeecc2680 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -815,6 +815,7 @@ private: ASSERT_EQUALS("1 - 2", tokenizeAndStringify("1-2")); ASSERT_EQUALS("foo ( -1 ) - 2", tokenizeAndStringify("foo(-1)-2")); ASSERT_EQUALS("int f ( ) { return -2 ; }", tokenizeAndStringify("int f(){return -2;}")); + ASSERT_EQUALS("int x [ 2 ] = { -2 , 1 }", tokenizeAndStringify("int x[2] = {-2,1}")); }