Ticket #6187: Avoid infinite loop if eraseDeadCode does not remove anything (invalid goto into a dead loop's body).
This commit is contained in:
parent
ccd80e3407
commit
f088588c88
|
@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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() {
|
||||
|
|
Loading…
Reference in New Issue