Fixed #9137 (Tokenizer: Wrong handling of volatile pointer)

This commit is contained in:
Daniel Marjamäki 2019-08-03 12:28:50 +02:00
parent c03df8e6b4
commit cdc602e1be
2 changed files with 5 additions and 1 deletions

View File

@ -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

View File

@ -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() {