From 0c78d6674ca95bf8677798f5f82514a701ac81fe Mon Sep 17 00:00:00 2001 From: chrchr-github Date: Fri, 21 Aug 2026 23:01:36 +0200 Subject: [PATCH 1/2] Partial fix for #14982 internalAstError for noexcept function with requires clause --- lib/templatesimplifier.cpp | 2 +- test/testsimplifytemplate.cpp | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/lib/templatesimplifier.cpp b/lib/templatesimplifier.cpp index 24cc0bcbe1d..455ed1f7850 100644 --- a/lib/templatesimplifier.cpp +++ b/lib/templatesimplifier.cpp @@ -3831,7 +3831,7 @@ void TemplateSimplifier::simplifyTemplates(const std::time_t maxtime) // Remove concepts/requires // TODO concepts are not removed yet for (Token *tok = mTokenList.front(); tok; tok = tok->next()) { - if (!Token::Match(tok, ")|>|>> requires %name%|(")) + if (!Token::Match(tok, ")|>|>>|const|final|noexcept|override requires %name%|(")) continue; const Token* end = skipRequires(tok->next()); if (end) diff --git a/test/testsimplifytemplate.cpp b/test/testsimplifytemplate.cpp index 6960b791426..b37ed03db34 100644 --- a/test/testsimplifytemplate.cpp +++ b/test/testsimplifytemplate.cpp @@ -314,6 +314,7 @@ class TestSimplifyTemplate : public TestFixture { TEST_CASE(requires3); TEST_CASE(requires4); TEST_CASE(requires5); + TEST_CASE(requires6); TEST_CASE(explicitBool1); TEST_CASE(explicitBool2); @@ -6696,6 +6697,22 @@ class TestSimplifyTemplate : public TestFixture { ASSERT_EQUALS(expected, tok(code)); } + void requires6() { + const char code[] = "template \n" // #14982 + "struct S {\n" + " static void f() noexcept\n" + " requires(N >= 5) {}\n" + " void g() const\n" + " requires(N >= 5) {}\n" + "};"; + const char expected[] = "template < int N > " + "struct S { " + "static void f ( ) noexcept { } " + "void g ( ) const { } " + "} ;"; + ASSERT_EQUALS(expected, tok(code)); + } + void explicitBool1() { const char code[] = "class Fred { explicit(true) Fred(int); };"; ASSERT_EQUALS("class Fred { explicit Fred ( int ) ; } ;", tok(code)); From 319700a9b061a8b55bbb5afb2a6141bc66248440 Mon Sep 17 00:00:00 2001 From: chrchr-github Date: Fri, 21 Aug 2026 23:05:00 +0200 Subject: [PATCH 2/2] Undo --- lib/templatesimplifier.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/templatesimplifier.cpp b/lib/templatesimplifier.cpp index 455ed1f7850..a194c0c8793 100644 --- a/lib/templatesimplifier.cpp +++ b/lib/templatesimplifier.cpp @@ -3831,7 +3831,7 @@ void TemplateSimplifier::simplifyTemplates(const std::time_t maxtime) // Remove concepts/requires // TODO concepts are not removed yet for (Token *tok = mTokenList.front(); tok; tok = tok->next()) { - if (!Token::Match(tok, ")|>|>>|const|final|noexcept|override requires %name%|(")) + if (!Token::Match(tok, ")|>|>>|const|noexcept requires %name%|(")) continue; const Token* end = skipRequires(tok->next()); if (end)