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, "> ("))
|
if (Token::simpleMatch(tok2, "> ("))
|
||||||
{
|
{
|
||||||
Token::eraseTokens(tok, tok2->tokAt(2));
|
Token *closeBracket = tok2->next()->link();
|
||||||
tok2 = tok;
|
if (closeBracket)
|
||||||
int parlevel = 0;
|
|
||||||
while (tok2->next() && parlevel >= 0)
|
|
||||||
{
|
{
|
||||||
tok2 = tok2->next();
|
Token::eraseTokens(tok, tok2->tokAt(2));
|
||||||
if (tok2->next()->str() == "(")
|
closeBracket->deleteThis();
|
||||||
++parlevel;
|
|
||||||
else if (tok2->next()->str() == ")")
|
|
||||||
--parlevel;
|
|
||||||
}
|
}
|
||||||
if (tok2->next())
|
|
||||||
tok2->deleteNext();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -672,8 +672,18 @@ private:
|
||||||
|
|
||||||
ASSERT_EQUALS(expected, sizeof_(code));
|
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