diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 9667bb7fe..85723fa51 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -6713,7 +6713,7 @@ void Tokenizer::simplifyVarDecl(Token * tokBegin, const Token * const tokEnd, co else if (std::strchr(";,", tok2->str()[0])) { // "type var =" => "type var; var =" const Token *varTok = type0->tokAt(typelen); - while (Token::Match(varTok, "*|&|const")) + while (Token::Match(varTok, "*|&|const|volatile")) varTok = varTok->next(); if (!varTok) syntaxError(tok2); // invalid code diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 3adef5e6d..4e68a4187 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -3645,6 +3645,10 @@ private: const char code4[] = "const void * const p = NULL;"; const char res4[] = "const void * const p ; p = NULL ;"; ASSERT_EQUALS(res4, tokenizeAndStringify(code4)); + + const char code5[] = "const void * volatile p = NULL;"; + const char res5[] = "const void * volatile p ; p = NULL ;"; + ASSERT_EQUALS(res5, tokenizeAndStringify(code5));; } void vardecl5() {