From 7497ccbfea3853366c9b7ddc9194ec9b148e857f Mon Sep 17 00:00:00 2001 From: Johan Crone Date: Tue, 3 Feb 2026 13:19:17 +0100 Subject: [PATCH 1/2] Fix #13735 AST:function name in parantheses - simplifyParenthesizedLibraryFunctions: Don't abort removal when preceeding is a keyword --- lib/tokenize.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 1092dfa9f55..576d22227da 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%")) + if (!lpar || (Token::Match(lpar->previous(), "%name%") && !lpar->previous()->isKeyword())) continue; const Token *ftok = rpar->previous(); if (mSettings.library.isNotLibraryFunction(ftok)) From 560d7ee78f1531b2c1fe1675af047e9716a992ce Mon Sep 17 00:00:00 2001 From: Johan Crone Date: Tue, 3 Feb 2026 14:22:57 +0100 Subject: [PATCH 2/2] Added test removeParantheses29 in order to test ticket #13735 --- test/testtokenize.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 38611c803e0..eff4a8d44f2 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -184,6 +184,7 @@ class TestTokenizer : public TestFixture { TEST_CASE(removeParentheses26); // Ticket #8875 a[0](0) TEST_CASE(removeParentheses27); TEST_CASE(removeParentheses28); // #12164 - don't remove parentheses in '(expr1) ? (expr2) : (expr3);' + TEST_CASE(removeParantheses29); // #13735 TEST_CASE(tokenize_double); TEST_CASE(tokenize_strings); @@ -2179,6 +2180,18 @@ class TestTokenizer : public TestFixture { ASSERT_EQUALS(exp, tokenizeAndStringify(code)); } + void removeParantheses29() { // Ticket #13735 + static char code[] = "double foo(void)\n" + "{\n" + "return (modf)(12.3, NULL);\n" + "}"; + static const char exp[] = "double foo ( )\n" + "{\n" + "return modf ( 12.3 , NULL ) ;\n" + "}"; + ASSERT_EQUALS(exp, tokenizeAndStringify(code)); + } + void tokenize_double() { const char code[] = "void f() {\n" " double a = 4.2;\n"