diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index b232e7bf35d..9d719cfaafa 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -2849,8 +2849,8 @@ bool Tokenizer::simplifyUsing() continue; Token* end = tok->tokAt(3); while (end && !Token::Match(end, "[;,]")) { - if (end->str() == "<" && end->link()) // skip template args - end = end->link()->next(); + if (end->str() == "<") // skip template args + end = end->findClosingBracket(); else end = end->next(); } diff --git a/test/testsimplifyusing.cpp b/test/testsimplifyusing.cpp index 2ae94df58af..46e0838b3e8 100644 --- a/test/testsimplifyusing.cpp +++ b/test/testsimplifyusing.cpp @@ -737,6 +737,16 @@ class TestSimplifyUsing : public TestFixture { ASSERT_EQUALS(expected, tok(code, Platform::Type::Native, /*debugwarnings*/ true)); ASSERT_EQUALS("", errout_str()); } + { + const char code[] = "class T : private std::vector> {\n" // #12521 + " using std::vector>::empty;\n" + "};\n"; + const char expected[] = "class T : private std :: vector < std :: pair < std :: string , const int * > > { " + "using empty = std :: vector < std :: pair < std :: string , const int * > > :: empty ; " + "} ;"; + ASSERT_EQUALS(expected, tok(code, Platform::Type::Native, /*debugwarnings*/ true)); + ASSERT_EQUALS("", errout_str()); + } } void simplifyUsing8970() {