From 8e79e5c1d3e9f3c5afeed52ac7c2e3006f006ef0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Mon, 11 Jan 2016 18:45:12 +0100 Subject: [PATCH] Fixed #7147 (TemplateSimplifier: specialized template class with inheritance) --- lib/templatesimplifier.cpp | 2 +- test/testsimplifytemplate.cpp | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) 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)