From 31738b53e11a299e42ed6ba18ab5baac689168f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludvig=20Gunne=20Lindstr=C3=B6m?= Date: Sun, 15 Feb 2026 13:45:23 +0100 Subject: [PATCH 1/2] Add test --- test/testtokenize.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index eff4a8d44f2..ee38b2a1dce 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -185,6 +185,7 @@ class TestTokenizer : public TestFixture { TEST_CASE(removeParentheses27); TEST_CASE(removeParentheses28); // #12164 - don't remove parentheses in '(expr1) ? (expr2) : (expr3);' TEST_CASE(removeParantheses29); // #13735 + TEST_CASE(removeParentheses30); TEST_CASE(tokenize_double); TEST_CASE(tokenize_strings); @@ -2192,6 +2193,19 @@ class TestTokenizer : public TestFixture { ASSERT_EQUALS(exp, tokenizeAndStringify(code)); } + void removeParentheses30() { + static char code[] = "void f (Node *node) {\n" + " if (node->data && (node->provider)->free)\n" + " (node->provider)->free (node);\n" + "}\n"; + static const char exp[] = "void f ( Node * node ) {\n" + "if ( node . data && ( node . provider ) . free ) {\n" + "node . provider . free ( node ) ; }\n" + "}"; + ASSERT_EQUALS(exp, tokenizeAndStringify(code)); + (void) errout_str(); + } + void tokenize_double() { const char code[] = "void f() {\n" " double a = 4.2;\n" From 8afd9edc5505e3525e4556ddf7b5fed8072cc109 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludvig=20Gunne=20Lindstr=C3=B6m?= Date: Sun, 15 Feb 2026 12:05:56 +0100 Subject: [PATCH 2/2] Fix #14494 --- lib/tokenize.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 7c15be961bc..b0c02fa4b01 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -3790,7 +3790,7 @@ void Tokenizer::simplifyParenthesizedLibraryFunctions() if (!Token::simpleMatch(tok, ") (")) continue; Token *rpar = tok, *lpar = tok->link(); - if (!lpar || (Token::Match(lpar->previous(), "%name%") && !lpar->previous()->isKeyword())) + if (!lpar || (Token::Match(lpar->previous(), "%name%") && !Token::Match(lpar->previous(), "return|delete|throw"))) continue; const Token *ftok = rpar->previous(); if (mSettings.library.isNotLibraryFunction(ftok))