diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index af2323484ca..3fdb1de33ba 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -1843,6 +1843,7 @@ void Tokenizer::simplifyTypedefCpp() } simplifyType = simplifyType && (!inEnumClass || Token::simpleMatch(tok2->previous(), "=")); + simplifyType = simplifyType && !(Token::simpleMatch(tok2->next(), "<") && Token::simpleMatch(typeEnd, ">")); if (simplifyType) { mTypedefInfo.back().used = true; diff --git a/test/testsimplifytypedef.cpp b/test/testsimplifytypedef.cpp index 2b4080eed64..941f779c311 100644 --- a/test/testsimplifytypedef.cpp +++ b/test/testsimplifytypedef.cpp @@ -211,6 +211,7 @@ class TestSimplifyTypedef : public TestFixture { TEST_CASE(simplifyTypedef144); // #9353 TEST_CASE(simplifyTypedef145); // #9353 TEST_CASE(simplifyTypedef146); + TEST_CASE(simplifyTypedef147); TEST_CASE(simplifyTypedefFunction1); TEST_CASE(simplifyTypedefFunction2); // ticket #1685 @@ -3389,6 +3390,25 @@ class TestSimplifyTypedef : public TestFixture { ASSERT_EQUALS("namespace N { struct S { } ; struct T { void f ( int * ) ; } ; } void N :: T :: f ( int * ) { }", tok(code)); } + void simplifyTypedef147() { + const char* code{}; + code = "namespace N {\n" // #12014 + " template\n" + " struct S {};\n" + "}\n" + "typedef N::S S;\n" + "namespace N {\n" + " template\n" + " struct U {\n" + " S operator()() {\n" + " return {};\n" + " }\n" + " };\n" + "}\n"; + ASSERT_EQUALS("namespace N { template < typename T > struct S { } ; } namespace N { template < typename T > struct U { S < T > operator() ( ) { return { } ; } } ; }", + tok(code)); + } + void simplifyTypedefFunction1() { { const char code[] = "typedef void (*my_func)();\n"