From 056848f225b63a207d3a3004d3bc134e3ca84fc7 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Thu, 29 Jan 2026 13:36:25 +0100 Subject: [PATCH 1/2] Update tokenize.cpp --- lib/tokenize.cpp | 29 +++++++++-------------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index af22c77f0dd..8ac034c86fc 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -5721,18 +5721,6 @@ bool Tokenizer::simplifyTokenList1(const char FileName[]) findGarbageCode(); }); - // if (x) MACRO() .. - for (const Token *tok = list.front(); tok; tok = tok->next()) { - if (Token::simpleMatch(tok, "if (")) { - tok = tok->linkAt(1); - if (Token::Match(tok, ") %name% (") && - tok->next()->isUpperCaseName() && - Token::Match(tok->linkAt(2), ") {|else")) { - syntaxError(tok->next()); - } - } - } - if (Settings::terminated()) return false; @@ -5763,14 +5751,6 @@ bool Tokenizer::simplifyTokenList1(const char FileName[]) // simplify compound statements: "[;{}] ( { code; } ) ;"->"[;{}] code;" simplifyCompoundStatements(); - // check for simple syntax errors.. - for (const Token *tok = list.front(); tok; tok = tok->next()) { - if (Token::simpleMatch(tok, "> struct {") && - Token::simpleMatch(tok->linkAt(2), "} ;")) { - syntaxError(tok); - } - } - if (!simplifyAddBraces()) return false; @@ -8760,6 +8740,13 @@ void Tokenizer::findGarbageCode() const if (!Token::simpleMatch(tok->linkAt(1)->linkAt(2), ") ;")) syntaxError(tok->linkAt(1)->linkAt(2)); } + // if (x) MACRO() .. + if (Token::simpleMatch(tok, "if (")) { + const Token* tok2 = tok->linkAt(1); + if (Token::Match(tok2, ") %name% (") && tok2->next()->isUpperCaseName() && + Token::Match(tok2->linkAt(2), ") {|else")) + syntaxError(tok2->next()); + } } // keyword keyword @@ -9120,6 +9107,8 @@ void Tokenizer::findGarbageCode() const syntaxError(tok); if (Token::simpleMatch(tok, ": template") && !Token::Match(tok->tokAt(-1), "public|private|protected")) syntaxError(tok); + if (Token::Match(tok, "> class|struct|union {") && Token::simpleMatch(tok->linkAt(2), "} ;")) { + syntaxError(tok); if (!Token::simpleMatch(tok, "template <")) continue; if (!tok->tokAt(2) || tok->tokAt(2)->isLiteral()) From e99b12e0374fc27b13210c6f3c86ab2960d07c2a Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Thu, 29 Jan 2026 13:46:20 +0100 Subject: [PATCH 2/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 8ac034c86fc..a8b6aa2a35a 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -9107,7 +9107,7 @@ void Tokenizer::findGarbageCode() const syntaxError(tok); if (Token::simpleMatch(tok, ": template") && !Token::Match(tok->tokAt(-1), "public|private|protected")) syntaxError(tok); - if (Token::Match(tok, "> class|struct|union {") && Token::simpleMatch(tok->linkAt(2), "} ;")) { + if (Token::Match(tok, "> class|struct|union {") && Token::simpleMatch(tok->linkAt(2), "} ;")) syntaxError(tok); if (!Token::simpleMatch(tok, "template <")) continue;