Fixed #645 (Tokenizer::simplifyCasts() breaks link() if casts function)
http://sourceforge.net/apps/trac/cppcheck/ticket/645
This commit is contained in:
parent
dade31b6d7
commit
0fb89f8afa
|
@ -2263,19 +2263,12 @@ void Tokenizer::simplifyCasts()
|
|||
|
||||
if (Token::simpleMatch(tok2, "> ("))
|
||||
{
|
||||
Token::eraseTokens(tok, tok2->tokAt(2));
|
||||
tok2 = tok;
|
||||
int parlevel = 0;
|
||||
while (tok2->next() && parlevel >= 0)
|
||||
Token *closeBracket = tok2->next()->link();
|
||||
if (closeBracket)
|
||||
{
|
||||
tok2 = tok2->next();
|
||||
if (tok2->next()->str() == "(")
|
||||
++parlevel;
|
||||
else if (tok2->next()->str() == ")")
|
||||
--parlevel;
|
||||
Token::eraseTokens(tok, tok2->tokAt(2));
|
||||
closeBracket->deleteThis();
|
||||
}
|
||||
if (tok2->next())
|
||||
tok2->deleteNext();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -672,8 +672,18 @@ private:
|
|||
|
||||
ASSERT_EQUALS(expected, sizeof_(code));
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
// ticket #645
|
||||
const char code[] = "void f()\n"
|
||||
"{\n"
|
||||
" return dynamic_cast<Foo *>((bar()));\n"
|
||||
"}\n";
|
||||
const std::string expected(" void f ( ) { return bar ( ) ; }");
|
||||
|
||||
ASSERT_EQUALS(expected, sizeof_(code));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue