Fixed #7147 (TemplateSimplifier: specialized template class with inheritance)

This commit is contained in:
Daniel Marjamäki 2016-01-11 18:45:12 +01:00
parent e03e9fbbcf
commit 8e79e5c1d3
2 changed files with 8 additions and 1 deletions

View File

@ -430,7 +430,7 @@ std::set<std::string> TemplateSimplifier::expandSpecialized(Token *tokens)
ostr << " ";
ostr << tok3->str();
}
if (!Token::Match(tok3, "> (|{"))
if (!Token::Match(tok3, "> (|{|:"))
continue;
s = ostr.str();
}

View File

@ -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 T> class A { unsigned foo(); }; "
"template<class T> unsigned A<T>::foo() { return 0; }", 19));
}
void expandSpecialized() {
ASSERT_EQUALS("class A<int> { } ;", tok("template<> class A<int> {};"));
ASSERT_EQUALS("class A<int> : public B { } ;", tok("template<> class A<int> : public B {};"));
}
};
REGISTER_TEST(TestSimplifyTemplate)