diff --git a/lib/templatesimplifier.cpp b/lib/templatesimplifier.cpp index 5213df7fd..97f63cd5c 100644 --- a/lib/templatesimplifier.cpp +++ b/lib/templatesimplifier.cpp @@ -430,7 +430,7 @@ std::set TemplateSimplifier::expandSpecialized(Token *tokens) ostr << " "; ostr << tok3->str(); } - if (!Token::Match(tok3, "> (|{")) + if (!Token::Match(tok3, "> (|{|:")) continue; s = ostr.str(); } diff --git a/test/testsimplifytemplate.cpp b/test/testsimplifytemplate.cpp index 7138d4951..b54b49735 100644 --- a/test/testsimplifytemplate.cpp +++ b/test/testsimplifytemplate.cpp @@ -101,6 +101,8 @@ private: TEST_CASE(templateParameters); TEST_CASE(templateNamePosition); + + TEST_CASE(expandSpecialized); } std::string tok(const char code[], bool simplify = true, bool debugwarnings = false, Settings::PlatformType type = Settings::Native) { @@ -1318,6 +1320,11 @@ private: TODO_ASSERT_EQUALS(7, -1, templateNamePositionHelper("template class A { unsigned foo(); }; " "template unsigned A::foo() { return 0; }", 19)); } + + void expandSpecialized() { + ASSERT_EQUALS("class A { } ;", tok("template<> class A {};")); + ASSERT_EQUALS("class A : public B { } ;", tok("template<> class A : public B {};")); + } }; REGISTER_TEST(TestSimplifyTemplate)