diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index c4df03341..76133db55 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -4607,7 +4607,7 @@ bool Tokenizer::simplifyFunctionParameters() } // Find the function e.g. foo( x ) or foo( x, y ) - else if (Token::Match(tok, "%var% ( %var% [,)]")) { + else if (Token::Match(tok, "%var% ( %var% [,)]") && 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 00f1571ef..35fd01a1e 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -290,6 +290,7 @@ private: TEST_CASE(simplifyFunctionParameters); TEST_CASE(simplifyFunctionParameters1); // #3721 + TEST_CASE(simplifyFunctionParameters2); // #4430 TEST_CASE(simplifyFunctionParametersErrors); TEST_CASE(removeParentheses1); // Ticket #61 @@ -4685,6 +4686,16 @@ private: "}", tokenizeAndStringify(code)); } + void simplifyFunctionParameters2() { // #4430 + const char code[] = "class Item { " + "int i ; " + "public: " + "Item ( int i ) ; " + "} ; " + "Item :: Item ( int i ) : i ( i ) { }"; + ASSERT_EQUALS(code, tokenizeAndStringify(code)); + } + void simplifyFunctionParametersErrors() { //same parameters... tokenizeAndStringify("void foo(x, x)\n"