This patch simplifies the function pointer return type code and allows more complex return types.

This commit is contained in:
Robert Reif 2010-01-21 18:01:09 +01:00 committed by Daniel Marjamäki
parent e9e64033e7
commit 9f0b9551cf
2 changed files with 35 additions and 4 deletions

View File

@ -644,10 +644,6 @@ void Tokenizer::simplifyTypedef()
} }
} }
} }
else if (functionPtr)
{
tok2->str(type1);
}
else else
{ {
tok2->str(type1); tok2->str(type1);

View File

@ -2693,6 +2693,41 @@ private:
ASSERT_EQUALS(expected, tok(code, false)); ASSERT_EQUALS(expected, tok(code, false));
} }
{
const char code[] = "class Fred {\n"
" typedef unsigned int * (*testfp)(unsigned int *);\n"
" testfp get() { return test; }\n"
" static unsigned int * test(unsigned int * p) { return p; }\n"
"};\n";
const char expected[] =
"class Fred { "
"; "
"unsigned int * ( * get ( ) ) ( unsigned int * ) { return test ; } "
"static unsigned int * test ( unsigned int * p ) { return p ; } "
"} ;";
ASSERT_EQUALS(expected, tok(code, false));
}
{
const char code[] = "class Fred {\n"
" typedef const unsigned int * (*testfp)(const unsigned int *);\n"
" testfp get() { return test; }\n"
" static const unsigned int * test(const unsigned int * p) { return p; }\n"
"};\n";
// static const gets changed to const static
const char expected[] =
"class Fred { "
"; "
"const unsigned int * ( * get ( ) ) ( const unsigned int * ) { return test ; } "
"const static unsigned int * test ( const unsigned int * p ) { return p ; } "
"} ;";
ASSERT_EQUALS(expected, tok(code, false));
}
{ {
const char code[] = "class Fred {\n" const char code[] = "class Fred {\n"
" typedef void * (*testfp)(void *);\n" " typedef void * (*testfp)(void *);\n"