Merge pull request #450 from simartin/ticket_6187

Ticket #6187: Avoid infinite loop if eraseDeadCode does not remove anything
This commit is contained in:
amai2012 2014-10-06 08:59:56 +02:00
commit cddb4af10b
2 changed files with 11 additions and 2 deletions

View File

@ -9066,8 +9066,7 @@ void Tokenizer::simplifyWhile0()
if (Token::simpleMatch(tok->next()->link(), ") {")) {
Token *end = tok->next()->link();
end = end->next()->link();
tok = tok->previous();
eraseDeadCode(tok, end->next());
eraseDeadCode(tok->previous(), end->next());
}
}
}

View File

@ -2372,6 +2372,16 @@ 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() {