From e1beb70f80787d6d22e439306a810517e52f2c41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Wed, 5 Aug 2009 20:15:48 +0200 Subject: [PATCH] Fixed #558 (Tokenizer: Bad simplification of 'for(unsigned i = 0; i < 100; ++i)') --- src/tokenize.cpp | 4 ++-- test/testtokenize.cpp | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/tokenize.cpp b/src/tokenize.cpp index ae2c54656..fa87f205d 100644 --- a/src/tokenize.cpp +++ b/src/tokenize.cpp @@ -2442,10 +2442,10 @@ void Tokenizer::unsignedint() if (!Token::Match(tok, "unsigned %var% [;,=]")) continue; - // Previous token should either be a symbol or one of "{};" + // Previous token should either be a symbol or one of "{};(" if (tok->previous() && !tok->previous()->isName() && - !Token::Match(tok->previous(), "[{};]")) + !Token::Match(tok->previous(), "[{};(]")) continue; // next token should not be a standard type? diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 80acea18e..55b7e4574 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -2320,6 +2320,13 @@ private: ASSERT_EQUALS(code2, tokenizeAndStringify(code1)); } + // insert "int" after "unsigned".. + { + const char code1[] = "for (unsigned i=0; i<10; i++)"; + const char code2[] = "for ( unsigned int i = 0 ; i < 10 ; i ++ )"; + ASSERT_EQUALS(code2, tokenizeAndStringify(code1)); + } + } };