diff --git a/src/tokenize.cpp b/src/tokenize.cpp index 0d6fe3c4f..cc7b232d9 100644 --- a/src/tokenize.cpp +++ b/src/tokenize.cpp @@ -1031,13 +1031,13 @@ void Tokenizer::simplifyTokenList() } } - else if (Token::Match(type0, "%type% %var% [ %num% ] ,|=")) + else if (Token::Match(type0, "%type% %var% [ %num% ] ,")) { tok2 = type0->tokAt(5); // The ',' token typelen = 1; } - else if (Token::Match(type0, "%type% * %var% [ %num% ] ,|=")) + else if (Token::Match(type0, "%type% * %var% [ %num% ] ,")) { tok2 = type0->tokAt(6); // The ',' token typelen = 1; diff --git a/test/testsimplifytokens.cpp b/test/testsimplifytokens.cpp index 5a1c17d39..d2d425310 100644 --- a/test/testsimplifytokens.cpp +++ b/test/testsimplifytokens.cpp @@ -64,6 +64,7 @@ private: TEST_CASE(redundant_plus); TEST_CASE(parantheses1); TEST_CASE(paranthesesVar); // Remove redundant parantheses around variable .. "( %var% )" + TEST_CASE(declareVar); TEST_CASE(elseif1); @@ -321,6 +322,11 @@ private: ASSERT_EQUALS("cast < char * > ( p ) ", tok("cast(p)")); } + void declareVar() + { + const char code[] = "void f ( ) { char str [ 100 ] = \"100\" ; } "; + ASSERT_EQUALS(code, tok(code)); + } std::string elseif(const char code[]) {