Fixed #1615 (False positive - C-style pointer casting)

This commit is contained in:
Robert Reif 2010-04-22 20:08:29 +02:00 committed by Daniel Marjamäki
parent 7d391b37c9
commit f4ce5a37d7
2 changed files with 17 additions and 1 deletions

View File

@ -1030,7 +1030,7 @@ void Tokenizer::simplifyTypedef()
{
if (tok2->next()->str() == "(")
tok2 = tok2->next()->link();
else if (tok2->next()->str() != "[")
else if (!Token::Match(tok2->next(), "[|>"))
{
tok2 = tok2->next();

View File

@ -184,6 +184,7 @@ private:
TEST_CASE(simplifyTypedef43); // ticket #1588
TEST_CASE(simplifyTypedef44);
TEST_CASE(simplifyTypedef45); // ticket #1613
TEST_CASE(simplifyTypedef46); // ticket #1615
TEST_CASE(reverseArraySyntax)
TEST_CASE(simplify_numeric_condition)
@ -3893,6 +3894,21 @@ private:
ASSERT_EQUALS("", errout.str());
}
void simplifyTypedef46()
{
// ticket # 1615
const char code[] = "typedef void (*my_func)(arg_class*);\n"
"std::queue<my_func> func_queue;";
// The expected result..
const std::string expected("; "
"std :: queue < void ( * ) ( arg_class * ) > func_queue ;");
ASSERT_EQUALS(expected, sizeof_(code));
checkSimplifyTypedef(code);
ASSERT_EQUALS("", errout.str());
}
void reverseArraySyntax()
{
ASSERT_EQUALS("a [ 13 ]", tok("13[a]"));