diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 0b8fd2c32..bd6789742 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -2041,11 +2041,16 @@ namespace { base += ' '; base += tok->str(); tok = tok->next(); - // skip template parameters + // add template parameters if (tok && tok->str() == "<") { - tok = tok->findClosingBracket(); - if (tok) - tok = tok->next(); + const Token* endTok = tok->findClosingBracket(); + if (endTok) { + endTok = endTok->next(); + while (tok != endTok) { + base += tok->str(); + tok = tok->next(); + } + } } } baseTypes.insert(base); diff --git a/test/testsimplifyusing.cpp b/test/testsimplifyusing.cpp index 272bde012..6074015a1 100644 --- a/test/testsimplifyusing.cpp +++ b/test/testsimplifyusing.cpp @@ -72,6 +72,7 @@ private: TEST_CASE(simplifyUsing23); TEST_CASE(simplifyUsing24); TEST_CASE(simplifyUsing25); + TEST_CASE(simplifyUsing26); // #11090 TEST_CASE(simplifyUsing8970); TEST_CASE(simplifyUsing8971); @@ -617,6 +618,34 @@ private: ASSERT_EQUALS(expected, tok(code)); } + void simplifyUsing26() { // #11090 + const char code[] = "namespace M {\n" + " struct A;\n" + " struct B;\n" + " struct C;\n" + " template\n" + " struct F {};\n" + " template<>\n" + " struct F : F {};\n" + " template<>\n" + " struct F : F {};\n" + "}\n" + "namespace N {\n" + " using namespace M;\n" + " using A = void;\n" + "}\n"; + const char expected[] = "namespace M { " + "struct A ; struct B ; struct C ; " + "struct F ; struct F ; struct F ; " + "struct F : F { } ; struct F : F { } ; " + "} " + "namespace N { " + "using namespace M ; " + "} " + "struct M :: F { } ;"; + ASSERT_EQUALS(expected, tok(code)); + } + void simplifyUsing8970() { const char code[] = "using V = std::vector;\n" "struct A {\n"