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)) 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"