Fixed #4710 (Template parser bug: const in constructor changes template names)
This commit is contained in:
parent
4e003c392e
commit
f8cf64afef
|
@ -473,6 +473,7 @@ std::list<Token *> TemplateSimplifier::getTemplateInstantiations(Token *tokens)
|
|||
if (!tok)
|
||||
break;
|
||||
} else if (Token::Match(tok->previous(), "[({};=] %var% <") ||
|
||||
Token::Match(tok->previous(), "%type% %var% <") ||
|
||||
Token::Match(tok->tokAt(-2), "[,:] private|protected|public %var% <")) {
|
||||
|
||||
// Add inner template instantiations first => go to the ">"
|
||||
|
|
|
@ -133,6 +133,7 @@ private:
|
|||
TEST_CASE(template38); // #4832 - crash on C++11 right angle brackets
|
||||
TEST_CASE(template39); // #4742 - freeze
|
||||
TEST_CASE(template40); // #5055 - template specialization outside struct
|
||||
TEST_CASE(template41); // #4710 - const in instantiation not handled perfectly
|
||||
TEST_CASE(template_unhandled);
|
||||
TEST_CASE(template_default_parameter);
|
||||
TEST_CASE(template_default_type);
|
||||
|
@ -2338,6 +2339,16 @@ private:
|
|||
ASSERT_EQUALS("struct A { template < typename T > struct X { T t ; } ; } ;", tok(code));
|
||||
}
|
||||
|
||||
void template41() { // #4710 - const in template instantiation not handled perfectly
|
||||
const char code1[] = "template<class T> struct X { };\n"
|
||||
"void f(const X<int> x) { }";
|
||||
ASSERT_EQUALS("void f ( const X<int> x ) { } struct X<int> { }", tok(code1));
|
||||
|
||||
const char code2[] = "template<class T> T f(T t) { return t; }\n"
|
||||
"int x() { return f<int>(123); }";
|
||||
ASSERT_EQUALS("int x ( ) { return f<int> ( 123 ) ; } int f<int> ( int t ) { return t ; }", tok(code2));
|
||||
}
|
||||
|
||||
void template_default_parameter() {
|
||||
{
|
||||
const char code[] = "template <class T, int n=3>\n"
|
||||
|
|
|
@ -1279,7 +1279,7 @@ private:
|
|||
"public:\n"
|
||||
" int f() { return C< ::D,int>::f(); }\n"
|
||||
"};");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
ASSERT_EQUALS("[test.cpp:1]: (debug) simplifyTemplates: bailing out\n", errout.str());
|
||||
}
|
||||
|
||||
void symboldatabase8() {
|
||||
|
|
Loading…
Reference in New Issue