diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 7bf3c419c..0fb2e60dc 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -4612,7 +4612,8 @@ bool Tokenizer::simplifyFunctionParameters() } // Find the function e.g. foo( x ) or foo( x, y ) - else if (Token::Match(tok, "%var% ( %var% [,)]") && tok->strAt(-1) != ":") { + else if (Token::Match(tok, "%var% ( %var% [,)]") && + !(tok->strAt(-1) == ":" || tok->strAt(-1) == ",")) { // We have found old style function, now we need to change it // First step: Get list of argument names in parenthesis diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 42477dafd..a5f375a27 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -293,6 +293,7 @@ private: TEST_CASE(simplifyFunctionParameters); TEST_CASE(simplifyFunctionParameters1); // #3721 TEST_CASE(simplifyFunctionParameters2); // #4430 + TEST_CASE(simplifyFunctionParameters3); // #4436 TEST_CASE(simplifyFunctionParametersErrors); TEST_CASE(removeParentheses1); // Ticket #61 @@ -4745,6 +4746,17 @@ private: ASSERT_EQUALS(code, tokenizeAndStringify(code)); } + void simplifyFunctionParameters3() { // #4436 + const char code[] = "class Item { " + "int i ; " + "int j ; " + "public: " + "Item ( int i , int j ) ; " + "} ; " + "Item :: Item ( int i , int j ) : i ( i ) , j ( j ) { }"; + ASSERT_EQUALS(code, tokenizeAndStringify(code)); + } + void simplifyFunctionParametersErrors() { //same parameters... tokenizeAndStringify("void foo(x, x)\n"