diff --git a/lib/templatesimplifier.cpp b/lib/templatesimplifier.cpp index 02f554c60..1b824e6d1 100644 --- a/lib/templatesimplifier.cpp +++ b/lib/templatesimplifier.cpp @@ -720,6 +720,14 @@ int TemplateSimplifier::getTemplateNamePosition(const Token *tok) namepos = 2; else if (Token::Match(tok, "> %type% %type% *|&| %type% (")) namepos = 3; + else if ((Token::Match(tok, "> %type% <") && Token::Match(tok->linkAt(2), "> :: %type% (")) || + (Token::Match(tok, "> %type% %type% <") && Token::Match(tok->linkAt(3), "> :: %type% ("))) { + namepos = 2 + (Token::Match(tok, "> %type% %type%")); + const Token *end = tok->linkAt(namepos); + for(const Token *tok2 = tok->tokAt(namepos) ; tok2 != end ; tok2 = tok2->next()) + ++namepos; + namepos += 2; + } else if (Token::Match(tok, "> %type% *|&| %type% :: %type% (")) { namepos = 4; starAmpPossiblePosition = 2; diff --git a/test/testsimplifytemplate.cpp b/test/testsimplifytemplate.cpp index e4980c40e..a8317bf1d 100644 --- a/test/testsimplifytemplate.cpp +++ b/test/testsimplifytemplate.cpp @@ -1372,8 +1372,14 @@ private: TODO_ASSERT_EQUALS(7, -1, templateNamePositionHelper("class A { class B { template const unsigned foo(); }; } ; " "template const unsigned A::B::foo() { return 0; }", 25)); // Template class member - TODO_ASSERT_EQUALS(7, -1, templateNamePositionHelper("template class A { unsigned foo(); }; " - "template unsigned A::foo() { return 0; }", 19)); + ASSERT_EQUALS(6, templateNamePositionHelper("template class A { A(); }; " + "template A::A() {}", 18)); + ASSERT_EQUALS(8, templateNamePositionHelper("template class A { A(); }; " + "template A::A() {}", 24)); + ASSERT_EQUALS(7, templateNamePositionHelper("template class A { unsigned foo(); }; " + "template unsigned A::foo() { return 0; }", 19)); + ASSERT_EQUALS(9, templateNamePositionHelper("template class A { unsigned foo(); }; " + "template unsigned A::foo() { return 0; }", 25)); } void expandSpecialized() {