diff --git a/lib/templatesimplifier.cpp b/lib/templatesimplifier.cpp index 1fa2dacd2..086c92f2e 100644 --- a/lib/templatesimplifier.cpp +++ b/lib/templatesimplifier.cpp @@ -1047,7 +1047,7 @@ void TemplateSimplifier::expandTemplate( start = templateDeclarationToken->next(); end = templateDeclarationNameToken->linkAt(1)->next(); } - while (!Token::Match(end, ";|{")) + while (!Token::Match(end, ";|{|:")) end = end->next(); std::map links; diff --git a/test/testsimplifytemplate.cpp b/test/testsimplifytemplate.cpp index adafba8db..9f0482d48 100644 --- a/test/testsimplifytemplate.cpp +++ b/test/testsimplifytemplate.cpp @@ -120,6 +120,7 @@ private: TEST_CASE(template80); TEST_CASE(template81); TEST_CASE(template82); // 8603 + TEST_CASE(template83); 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) @@ -1593,6 +1594,20 @@ private: ASSERT_EQUALS(exp, tok(code)); } + void template83() { + const char code[] = "template\n" + "MultiConsumer::MultiConsumer() : sizeBuffer(0) {}\n" + "MultiReads::MultiReads() {\n" + " mc = new MultiConsumer();\n" + "}"; + const char exp[] = "MultiConsumer :: MultiConsumer ( ) ; " + "MultiReads :: MultiReads ( ) { " + "mc = new MultiConsumer ( ) ; " + "} " + "MultiConsumer :: MultiConsumer ( ) : sizeBuffer ( 0 ) { }"; + 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"