From aa0c449bf8f1ab7ff2077b4807fbb726b651038e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludvig=20Gunne=20Lindstr=C3=B6m?= Date: Tue, 17 Jun 2025 11:44:56 +0200 Subject: [PATCH 1/2] add test --- test/testsimplifytemplate.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) 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" From aacaf7b344854bc79262e7b28f3aa43eb6c11ef5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludvig=20Gunne=20Lindstr=C3=B6m?= Date: Tue, 17 Jun 2025 11:41:35 +0200 Subject: [PATCH 2/2] fix #13770 --- lib/templatesimplifier.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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% ... )")) {