IncompleteStatement: Fixed false positive when '({..})' blocks are used

This commit is contained in:
Daniel Marjamäki 2014-04-24 06:32:29 +02:00
parent 5c98e4d039
commit 9406f3428a
2 changed files with 9 additions and 1 deletions

View File

@ -1878,8 +1878,10 @@ void Tokenizer::simplifyExternC()
void Tokenizer::simplifyRoundCurlyParentheses()
{
for (Token *tok = list.front(); tok; tok = tok->next()) {
while (Token::Match(tok, "[;{}] ( {") &&
while (Token::Match(tok, "[;{}:] ( {") &&
Token::simpleMatch(tok->linkAt(2), "} ) ;")) {
if (tok->str() == ":" && !Token::Match(tok->tokAt(-2),"[;{}] %type% :"))
break;
Token *end = tok->linkAt(2)->tokAt(-3);
if (Token::Match(end, "[;{}] %num%|%str% ;"))
end->deleteNext(2);

View File

@ -245,6 +245,12 @@ private:
" ({ do_something(); 0; });\n"
"}");
ASSERT_EQUALS("", errout.str());
check("void f() {\n"
"out:\n"
" ({ do_something(); 0; });\n"
"}");
ASSERT_EQUALS("", errout.str());
}
};