diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 25317d38de2..e8a30461917 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -2249,6 +2249,8 @@ void Tokenizer::simplifyTypedefCpp() tok2 = tok3->tokAt(3); else if (Token::Match(tok2->tokAt(3), "[(),;]")) tok2 = tok2->tokAt(2); + else if (Token::simpleMatch(tok2->tokAt(3), ">")) + tok2 = tok2->tokAt(2); else tok2 = tok2->tokAt(3); if (!tok2) diff --git a/test/testsimplifytypedef.cpp b/test/testsimplifytypedef.cpp index 3118afa31ce..4970e863c5d 100644 --- a/test/testsimplifytypedef.cpp +++ b/test/testsimplifytypedef.cpp @@ -214,6 +214,7 @@ class TestSimplifyTypedef : public TestFixture { TEST_CASE(simplifyTypedef148); TEST_CASE(simplifyTypedef149); TEST_CASE(simplifyTypedef150); + TEST_CASE(simplifyTypedef151); TEST_CASE(simplifyTypedefFunction1); TEST_CASE(simplifyTypedefFunction2); // ticket #1685 @@ -3530,6 +3531,18 @@ class TestSimplifyTypedef : public TestFixture { ASSERT_EQUALS(exp, tok(code)); } + void simplifyTypedef151() { + const char* code{}, *exp{}; + code = "namespace N {\n" // #12597 + " typedef int T[10];\n" + " const T* f() { return static_cast(nullptr); }\n" + "}\n"; + exp = "namespace N { " + "const int ( * f ( ) ) [ 10 ] { return static_cast < const int ( * ) [ 10 ] > ( nullptr ) ; } " + "}"; + ASSERT_EQUALS(exp, tok(code)); + } + void simplifyTypedefFunction1() { { const char code[] = "typedef void (*my_func)();\n"