From a153151e9376c8ba8ef183f37dd5282f2a79c7a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludvig=20Gunne=20Lindstr=C3=B6m?= Date: Fri, 21 Aug 2026 11:29:36 +0200 Subject: [PATCH 1/2] test --- test/testtokenize.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 600d457e944..3ca73a2c2d1 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -435,6 +435,7 @@ class TestTokenizer : public TestFixture { TEST_CASE(astthrowdelete); TEST_CASE(asttrailingdecltype); TEST_CASE(astnoexcept); + TEST_CASE(astnoexceptrequires); TEST_CASE(astvardecl); TEST_CASE(astnewscoped); TEST_CASE(astdecltypescope); @@ -7582,6 +7583,9 @@ class TestTokenizer : public TestFixture { ASSERT_EQUALS("noexceptaswap.b((", testAst("void f() noexcept(noexcept(a.swap(b))) {}")); ASSERT_EQUALS("{([ noexceptaswap.b((", testAst("[]() noexcept(noexcept(a.swap(b))) {}")); } + void astnoexceptrequires() { + ASSERT_EQUALS("N5>=", testAst("void f() noexcept requires (N >= 5) {}")); + } //Verify that returning a newly constructed object generates the correct AST even when the class name is scoped //Addresses https://trac.cppcheck.net/ticket/9700 From 8787eb3b04bd939c37707d25a4f4058908225065 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludvig=20Gunne=20Lindstr=C3=B6m?= Date: Fri, 21 Aug 2026 11:29:40 +0200 Subject: [PATCH 2/2] fix --- lib/tokenlist.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tokenlist.cpp b/lib/tokenlist.cpp index ca509904db3..99876fb94e5 100644 --- a/lib/tokenlist.cpp +++ b/lib/tokenlist.cpp @@ -1631,7 +1631,7 @@ static Token * createAstAtToken(Token *tok) do { tok2 = tok2->next(); tok2->setCpp11init(false); - if (Token::Match(tok2, "decltype|noexcept (")) { + if (Token::Match(tok2, "decltype|noexcept|requires (")) { AST_state state(cpp); Token *tok3 = tok2->tokAt(2); compileExpression(tok3, state);