diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 5992b7a43..d9dd42a6f 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -940,6 +940,10 @@ void Tokenizer::simplifyTypedef() tok->deleteThis(); tok->deleteThis(); tok->deleteThis(); + if (tok->next()) + tok->deleteThis(); + //now the next token to process is 'tok', not 'tok->next()'; + goback = true; continue; } else { const std::string pattern("struct " + tok->strAt(2) + " {|:"); @@ -1102,6 +1106,9 @@ void Tokenizer::simplifyTypedef() if (typeName->str() == "void") { unsupportedTypedef(typeDef); tok = deleteInvalidTypedef(typeDef); + if (tok == _tokens) + //now the next token to process is 'tok', not 'tok->next()'; + goback = true; continue; } @@ -1111,6 +1118,9 @@ void Tokenizer::simplifyTypedef() Token::Match(tok->linkAt(offset)->tokAt(-3), ":: * %var% ) (")) { unsupportedTypedef(typeDef); tok = deleteInvalidTypedef(typeDef); + if (tok == _tokens) + //now the next token to process is 'tok', not 'tok->next()'; + goback = true; continue; } @@ -1152,6 +1162,9 @@ void Tokenizer::simplifyTypedef() else { unsupportedTypedef(typeDef); tok = deleteInvalidTypedef(typeDef); + if (tok == _tokens) + //now the next token to process is 'tok', not 'tok->next()'; + goback = true; continue; } } @@ -1289,6 +1302,9 @@ void Tokenizer::simplifyTypedef() else { unsupportedTypedef(typeDef); tok = deleteInvalidTypedef(typeDef); + if (tok == _tokens) + //now the next token to process is 'tok', not 'tok->next()'; + goback = true; continue; } diff --git a/test/testsimplifytokens.cpp b/test/testsimplifytokens.cpp index 0bf3c5752..32f1d97e4 100644 --- a/test/testsimplifytokens.cpp +++ b/test/testsimplifytokens.cpp @@ -3611,10 +3611,8 @@ private: "abc e1;\n" "XYZ e2;"; - const char expected[] = - "; " - "int e1 ; " - "int e2 ;"; + const char expected[] = "int e1 ; " + "int e2 ;"; ASSERT_EQUALS(expected, tok(code, false)); } @@ -4878,7 +4876,7 @@ private: " localEntitiyAddFunc_t f;\n" "}\n"; // The expected result.. - const std::string expected("; void f ( ) { int b ; int * f ; }"); + const std::string expected("void f ( ) { int b ; int * f ; }"); ASSERT_EQUALS(expected, sizeof_(code, false)); // Check for output..