diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index e922f677a..90cb1cc93 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -1309,8 +1309,17 @@ void Tokenizer::simplifyTypedef() while (Token::Match(tok2, "%var% ::")) tok2 = tok2->tokAt(2); + if (tok2->str() == "(" && + tok2->link()->next()->str() == "(") + { + tok2 = tok2->link(); + + if (tok2->next()->str() == "(") + tok2 = tok2->next()->link(); + } + // skip over typedef parameter - if (tok2->next()->str() == "(") + else if (tok2->next()->str() == "(") { tok2 = tok2->next()->link(); diff --git a/test/testsimplifytokens.cpp b/test/testsimplifytokens.cpp index c24a142b9..0fb2a720d 100644 --- a/test/testsimplifytokens.cpp +++ b/test/testsimplifytokens.cpp @@ -224,6 +224,7 @@ private: TEST_CASE(simplifyTypedef64); TEST_CASE(simplifyTypedef65); // ticket #2314 TEST_CASE(simplifyTypedef66); // ticket #2341 + TEST_CASE(simplifyTypedef67); // ticket #2354 TEST_CASE(simplifyTypedefFunction1); TEST_CASE(simplifyTypedefFunction2); // ticket #1685 @@ -4620,6 +4621,20 @@ private: ASSERT_EQUALS("", errout.str()); } + void simplifyTypedef67() // ticket #2354 + { + const char code[] = "typedef int ( * Function ) ( ) ;\n" + "void f ( ) {\n" + " ((Function * (*) (char *, char *, int, int)) global[6]) ( \"assoc\", \"eggdrop\", 106, 0);\n" + "}\n"; + const std::string expected = "; " + "void f ( ) { " + "( ( int ( * * ( * ) ( char * , char * , int , int ) ) ( ) ) global [ 6 ] ) ( \"assoc\" , \"eggdrop\" , 106 , 0 ) ; " + "}"; + ASSERT_EQUALS(expected, sizeof_(code)); + ASSERT_EQUALS("", errout.str()); + } + void simplifyTypedefFunction1() { {