diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 377e71495..ae3c67631 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -644,10 +644,6 @@ void Tokenizer::simplifyTypedef() } } } - else if (functionPtr) - { - tok2->str(type1); - } else { tok2->str(type1); diff --git a/test/testsimplifytokens.cpp b/test/testsimplifytokens.cpp index 689fd08d6..dd6391ea8 100644 --- a/test/testsimplifytokens.cpp +++ b/test/testsimplifytokens.cpp @@ -2693,6 +2693,41 @@ private: 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" " typedef void * (*testfp)(void *);\n"