Fixed a bug in Tokenizer::concatenateNegativeNumber.
The first negative number inside a '{}' list was not simplified correctly.
This commit is contained in:
parent
ffe657128f
commit
5fb2115e9d
|
@ -2148,7 +2148,7 @@ void Tokenizer::simplifyNull()
|
||||||
void Tokenizer::concatenateNegativeNumber()
|
void Tokenizer::concatenateNegativeNumber()
|
||||||
{
|
{
|
||||||
for (Token *tok = list.front(); tok; tok = tok->next()) {
|
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->deleteNext();
|
||||||
tok->next()->str("-" + tok->next()->str());
|
tok->next()->str("-" + tok->next()->str());
|
||||||
}
|
}
|
||||||
|
|
|
@ -815,6 +815,7 @@ private:
|
||||||
ASSERT_EQUALS("1 - 2", tokenizeAndStringify("1-2"));
|
ASSERT_EQUALS("1 - 2", tokenizeAndStringify("1-2"));
|
||||||
ASSERT_EQUALS("foo ( -1 ) - 2", tokenizeAndStringify("foo(-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 f ( ) { return -2 ; }", tokenizeAndStringify("int f(){return -2;}"));
|
||||||
|
ASSERT_EQUALS("int x [ 2 ] = { -2 , 1 }", tokenizeAndStringify("int x[2] = {-2,1}"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue