Fixed #4024 (Tokenizer::simplifyFlowControl removes pieces of code inside a class if 'exit' is a member function).
This commit is contained in:
parent
09fd3a6ed7
commit
9e916eec66
|
@ -3643,7 +3643,8 @@ void Tokenizer::simplifyFlowControl()
|
||||||
tok = tok->next();
|
tok = tok->next();
|
||||||
eraseDeadCode(tok, 0);
|
eraseDeadCode(tok, 0);
|
||||||
|
|
||||||
} else if (Token::Match(tok,"return|throw|exit|abort|goto")) {
|
} else if (Token::Match(tok,"return|goto") ||
|
||||||
|
(Token::Match(tok,"exit|throw|abort") && !Token::Match(tok->previous(),"%type%"))) {
|
||||||
//catch the first ';'
|
//catch the first ';'
|
||||||
for (Token *tok2 = tok->next(); tok2; tok2 = tok2->next()) {
|
for (Token *tok2 = tok->next(); tok2; tok2 = tok2->next()) {
|
||||||
if (tok2->str() == "(" || tok2->str() == "[") {
|
if (tok2->str() == "(" || tok2->str() == "[") {
|
||||||
|
|
|
@ -3440,6 +3440,28 @@ private:
|
||||||
"}";
|
"}";
|
||||||
ASSERT_EQUALS(expected, tok(code));
|
ASSERT_EQUALS(expected, tok(code));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
const char code[] = "class Fred\n"
|
||||||
|
"{\n"
|
||||||
|
"public:\n"
|
||||||
|
" bool foo() const { return f; }\n"
|
||||||
|
" bool exit();\n"
|
||||||
|
"\n"
|
||||||
|
"private:\n"
|
||||||
|
" bool f;\n"
|
||||||
|
"};\n";
|
||||||
|
const char expected[] = "class Fred "
|
||||||
|
"{"
|
||||||
|
" public:"
|
||||||
|
" bool foo ( ) const { return f ; }"
|
||||||
|
" bool exit ( ) ;"
|
||||||
|
""
|
||||||
|
" private:"
|
||||||
|
" bool f ; "
|
||||||
|
"} ;";
|
||||||
|
ASSERT_EQUALS(expected, tok(code));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void strcat1() {
|
void strcat1() {
|
||||||
|
|
Loading…
Reference in New Issue