diff --git a/lib/templatesimplifier.cpp b/lib/templatesimplifier.cpp index 1abaaa1ea60..52f91dacd29 100644 --- a/lib/templatesimplifier.cpp +++ b/lib/templatesimplifier.cpp @@ -4061,7 +4061,7 @@ void TemplateSimplifier::simplifyTemplates(const std::time_t maxtime) if (Token::Match(tok, "( ... %op%")) { op = tok->tokAt(2); args = tok->link()->previous(); - } else if (Token::Match(tok, "( %name% %op% ...")) { + } else if (Token::Match(tok, "( %name% %op% ...") && !Token::simpleMatch(tok->previous(), "] (")) { op = tok->tokAt(2); args = tok->link()->previous()->isName() ? nullptr : tok->next(); } else if (Token::Match(tok->link()->tokAt(-3), "%op% ... )")) { diff --git a/test/testsimplifytemplate.cpp b/test/testsimplifytemplate.cpp index 38f2360d644..3e57ed1d002 100644 --- a/test/testsimplifytemplate.cpp +++ b/test/testsimplifytemplate.cpp @@ -220,6 +220,7 @@ class TestSimplifyTemplate : public TestFixture { TEST_CASE(template179); TEST_CASE(template180); TEST_CASE(template181); + TEST_CASE(template182); // #13770 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_specialization_3); @@ -4636,6 +4637,15 @@ class TestSimplifyTemplate : public TestFixture { ASSERT_EQUALS(exp2, tok(code2)); } + void template182() { + const char code[] = "template \n" + "auto f() {\n" + " return [](auto&&...) {};\n" + "}\n"; + const char exp[] = "template < class ... > auto f ( ) { return [ ] ( auto && ... ) { } ; }"; + 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"