diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index b7666aecd..a17040fbc 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -9091,7 +9091,8 @@ void Tokenizer::simplifyWhile0() if (Token::simpleMatch(tok->next()->link(), ") {")) { Token *end = tok->next()->link(); end = end->next()->link(); - eraseDeadCode(tok->previous(), end->next()); + tok = tok->previous(); + eraseDeadCode(tok, end->next()); } } } diff --git a/test/testsimplifytokens.cpp b/test/testsimplifytokens.cpp index 690e8aa04..5eb890fba 100644 --- a/test/testsimplifytokens.cpp +++ b/test/testsimplifytokens.cpp @@ -2375,16 +2375,6 @@ private: ASSERT_EQUALS("void foo ( ) { exit ( 0 ) ; }", tokWithStdLib("void foo() { do { exit(0); } while (true); }")); - - // #6187 - tokWithStdLib("void foo() {\n" - " goto label;\n" - " for (int i = 0; i < 0; ++i) {\n" - " ;\n" - "label:\n" - " ;\n" - " }\n" - "}"); } void strcat1() {