From 9b9dd99226941fb72f8e955895b18480adfa1d00 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Thu, 22 Oct 2026 14:49:36 +0200 Subject: [PATCH 1/2] Update tokenize.cpp --- lib/tokenize.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 1d5b7436405..4adf43e1195 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -9427,7 +9427,7 @@ void Tokenizer::simplifyFunctionTryCatch() if (!Token::Match(tok, "try {|:")) continue; const Token* par = tok->previous(); - while (par && par->isKeyword()) + while (par && (par->isKeyword() || Token::Match(par, "final|override"))) par = par->previous(); if (!TokenList::isFunctionHead(par, "try")) // TODO: this is supposed to a list of characters and not strings continue; From aa91b3a3c299e53f2a717fece51f0d90049558f5 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Thu, 22 Oct 2026 14:50:47 +0200 Subject: [PATCH 2/2] Update testtokenize.cpp --- test/testtokenize.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 75a94c26aec..d864b342428 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -2028,6 +2028,15 @@ class TestTokenizer : public TestFixture { "void S::func() const\n" "try { f(); }\n" "catch (...) { g(); }\n")); + + ASSERT_EQUALS("struct D : B {\n" // #15126 + "void f ( ) override { try { } catch ( ... ) { } }\n" + "void g ( ) final { try { } catch ( ... ) { } }\n" + "} ;", + tokenizeAndStringify("struct D : B {\n" + " void f() override try {} catch (...) {}\n" + " void g() final try {} catch (...) {}\n" + "};\n")); } // Simplify "((..))" into "(..)"