Better handling of function pointer typedef

This commit is contained in:
Robert Reif 2010-05-10 17:50:40 +02:00 committed by Daniel Marjamäki
parent ac7515cdcc
commit a390f3c8f4
2 changed files with 26 additions and 0 deletions

View File

@ -878,6 +878,22 @@ void Tokenizer::simplifyTypedef()
continue;
}
}
else if (tok->tokAt(offset) && Token::Match(tok->tokAt(offset), "( %type% ("))
{
function = true;
if (tok->tokAt(offset)->link()->next())
{
typeName = tok->tokAt(offset + 1);
argStart = tok->tokAt(offset + 2);
argEnd = tok->tokAt(offset + 2)->link();
tok = tok->tokAt(offset)->link()->next();
}
else
{
// internal error
continue;
}
}
else
{
// unhandled typedef, skip it and continue

View File

@ -3932,6 +3932,16 @@ private:
"std :: queue < void ( * ) ( arg_class * ) > func_queue ;");
ASSERT_EQUALS(expected, sizeof_(code));
}
{
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));
}
}
void reverseArraySyntax()