diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 35baf29a2..3465928e8 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -7516,7 +7516,7 @@ void Tokenizer::simplifyVarDecl(Token * tokBegin, const Token * const tokEnd, co } while (Token::Match(varName, "%type% %type%")) { - if (varName->str() != "const") { + if (varName->str() != "const" && varName->str() != "volatile") { ++typelen; } varName = varName->next(); diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 5d87f6765..76ffa1bac 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -2526,13 +2526,22 @@ private: } void volatile_variables() { - const char code[] = "volatile int a=0;\n" - "volatile int b=0;\n" - "volatile int c=0;\n"; + { + const char code[] = "volatile int a=0;\n" + "volatile int b=0;\n" + "volatile int c=0;\n"; - const std::string actual(tokenizeAndStringify(code)); + const std::string actual(tokenizeAndStringify(code)); - ASSERT_EQUALS("volatile int a ; a = 0 ;\nvolatile int b ; b = 0 ;\nvolatile int c ; c = 0 ;", actual); + ASSERT_EQUALS("volatile int a ; a = 0 ;\nvolatile int b ; b = 0 ;\nvolatile int c ; c = 0 ;", actual); + } + { + const char code[] = "char *volatile s1, *volatile s2;\n"; // #11004 + + const std::string actual(tokenizeAndStringify(code)); + + ASSERT_EQUALS("char * volatile s1 ; char * volatile s2 ;", actual); + } }