Merge pull request #456 from simartin/ticket_6817_take2
Ticket #6187: Avoid infinite loop if eraseDeadCode does not remove anything (this time without memory corruption).
This commit is contained in:
commit
6088ba7951
|
@ -8967,10 +8967,13 @@ void Tokenizer::simplifyWhile0()
|
||||||
|
|
||||||
// remove "while (0) { .. }"
|
// remove "while (0) { .. }"
|
||||||
if (Token::simpleMatch(tok->next()->link(), ") {")) {
|
if (Token::simpleMatch(tok->next()->link(), ") {")) {
|
||||||
Token *end = tok->next()->link();
|
Token *end = tok->next()->link(), *old_prev = tok->previous();
|
||||||
end = end->next()->link();
|
end = end->next()->link();
|
||||||
tok = tok->previous();
|
eraseDeadCode(old_prev, end->next());
|
||||||
eraseDeadCode(tok, end->next());
|
if (old_prev && old_prev->next())
|
||||||
|
tok = old_prev->next();
|
||||||
|
else
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2393,6 +2393,16 @@ private:
|
||||||
|
|
||||||
ASSERT_EQUALS("void foo ( ) { exit ( 0 ) ; }",
|
ASSERT_EQUALS("void foo ( ) { exit ( 0 ) ; }",
|
||||||
tokWithStdLib("void foo() { do { exit(0); } while (true); }"));
|
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() {
|
void strcat1() {
|
||||||
|
|
Loading…
Reference in New Issue