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/7] 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/7] 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 "(..)" From b4102413e97b015b0ff6e8bbd76dde18d5dcdf09 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Mon, 26 Oct 2026 08:26:44 +0100 Subject: [PATCH 3/7] Update testtokenize.cpp [skip ci] --- test/testtokenize.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index d864b342428..cb5812e05b0 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -2032,11 +2032,18 @@ class TestTokenizer : public TestFixture { ASSERT_EQUALS("struct D : B {\n" // #15126 "void f ( ) override { try { } catch ( ... ) { } }\n" "void g ( ) final { try { } catch ( ... ) { } }\n" + "void i ( ) & override { try { } catch ( ... ) { } }\n" + "void j ( ) const && override { try { } catch ( ... ) { } }\n" + "auto k ( ) . std :: nullptr_t override { try { } catch ( ... ) { } }\n" "} ;", tokenizeAndStringify("struct D : B {\n" " void f() override try {} catch (...) {}\n" " void g() final try {} catch (...) {}\n" + " void i() & override try {} catch (...) {}\n" + " void j() const && override try {} catch (...) {}\n" + " auto k() -> std::nullptr_t override try {} catch (...) {}\n" "};\n")); + ASSERT_EQUALS("[test.cpp:6:5]: (debug) auto token with no type. [autoNoType]\n", errout_str()); } // Simplify "((..))" into "(..)" From cf6eb155a024ce620573a56e6a50a66dca12c53a Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Mon, 26 Oct 2026 08:28:03 +0100 Subject: [PATCH 4/7] Update tokenlist.cpp [skip ci] --- lib/tokenlist.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tokenlist.cpp b/lib/tokenlist.cpp index 26b24d649c8..ee10b8b4887 100644 --- a/lib/tokenlist.cpp +++ b/lib/tokenlist.cpp @@ -2379,7 +2379,7 @@ const Token * TokenList::isFunctionHead(const Token *tok, const std::string &suf tok = tok->linkAt(1)->next(); if (Token::Match(tok, "%name% (") && tok->isUpperCaseName()) tok = tok->linkAt(1)->next(); - if (tok && tok->originalName() == "->") { // trailing return type + if (tok && (tok->str() == "->" || tok->originalName() == "->")) { // trailing return type for (tok = tok->next(); tok && !Token::Match(tok, ";|{|override|final|}|)|]"); tok = tok->next()) if (tok->link() && Token::Match(tok, "<|[|(")) tok = tok->link(); From bb851aff57dd525206fc9e976e42e88627488f9b Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Mon, 26 Oct 2026 08:28:45 +0100 Subject: [PATCH 5/7] 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 4adf43e1195..1249bc2efe3 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() || Token::Match(par, "final|override"))) + while (par && (par->isKeyword() || Token::Match(par, "%name%|&|&&|->|::"))) par = par->previous(); if (!TokenList::isFunctionHead(par, "try")) // TODO: this is supposed to a list of characters and not strings continue; From 33f15a28235640fd1eef6778821a880e229f5158 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Mon, 26 Oct 2026 12:36:50 +0100 Subject: [PATCH 6/7] 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 1249bc2efe3..b861283fc56 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() || Token::Match(par, "%name%|&|&&|->|::"))) + while (par && !Token::Match(par, "[);]"))) par = par->previous(); if (!TokenList::isFunctionHead(par, "try")) // TODO: this is supposed to a list of characters and not strings continue; From c10d38f455197c978d78580dd60ab6f805bdd615 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Mon, 26 Oct 2026 13:15:08 +0100 Subject: [PATCH 7/7] 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 b861283fc56..7e9b80454ef 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 && !Token::Match(par, "[);]"))) + while (par && !Token::Match(par, "[);]")) par = par->previous(); if (!TokenList::isFunctionHead(par, "try")) // TODO: this is supposed to a list of characters and not strings continue;