diff --git a/lib/templatesimplifier.cpp b/lib/templatesimplifier.cpp index 4675148c1..efc4358c7 100644 --- a/lib/templatesimplifier.cpp +++ b/lib/templatesimplifier.cpp @@ -1571,7 +1571,7 @@ bool TemplateSimplifier::simplifyTemplateInstantiations( typeForNewName.clear(); break; } - if (Token::Match(tok3->tokAt(-2), "[<,] %name% <") && templateParameters(tok3) > 0) + if (Token::Match(tok3->tokAt(-2), "<|,|:: %name% <") && templateParameters(tok3) > 0) ++indentlevel; else if (indentlevel > 0 && Token::Match(tok3, "> [,>]")) --indentlevel; diff --git a/test/testsimplifytemplate.cpp b/test/testsimplifytemplate.cpp index 32f6f94a0..e9fdb6a32 100644 --- a/test/testsimplifytemplate.cpp +++ b/test/testsimplifytemplate.cpp @@ -100,6 +100,7 @@ private: TEST_CASE(template60); // handling of methods outside template definition TEST_CASE(template61); // daca2, kodi TEST_CASE(template62); // #8314 - inner template instantiation + TEST_CASE(template63); // #8576 - qualified type TEST_CASE(template_specialization_1); // #7868 - template specialization template struct S> {..}; TEST_CASE(template_specialization_2); // #7868 - template specialization template struct S> {..}; TEST_CASE(template_enum); // #6299 Syntax error in complex enum declaration (including template) @@ -1145,6 +1146,12 @@ private: ASSERT_EQUALS(exp, tok(code)); } + void template63() { // #8576 + const char code[] = "template struct TestClass { T m_hi; }; TestClass> objTest3;"; + const char exp[] = "TestClass> objTest3 ; struct TestClass> { std :: auto_ptr < v > m_hi ; } ;"; + ASSERT_EQUALS(exp, tok(code)); + } + void template_specialization_1() { // #7868 - template specialization template struct S> {..}; const char code[] = "template struct C {};\n" "template struct S {a};\n"