Fixed #4436 (FP: Member variable is not initialized in the constructor. (with two parameters))

This commit is contained in:
Robert Reif 2012-12-27 17:15:38 +01:00 committed by Daniel Marjamäki
parent 7368079949
commit 3e6d601982
2 changed files with 14 additions and 1 deletions

View File

@ -4612,7 +4612,8 @@ bool Tokenizer::simplifyFunctionParameters()
} }
// Find the function e.g. foo( x ) or foo( x, y ) // 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 // We have found old style function, now we need to change it
// First step: Get list of argument names in parenthesis // First step: Get list of argument names in parenthesis

View File

@ -293,6 +293,7 @@ private:
TEST_CASE(simplifyFunctionParameters); TEST_CASE(simplifyFunctionParameters);
TEST_CASE(simplifyFunctionParameters1); // #3721 TEST_CASE(simplifyFunctionParameters1); // #3721
TEST_CASE(simplifyFunctionParameters2); // #4430 TEST_CASE(simplifyFunctionParameters2); // #4430
TEST_CASE(simplifyFunctionParameters3); // #4436
TEST_CASE(simplifyFunctionParametersErrors); TEST_CASE(simplifyFunctionParametersErrors);
TEST_CASE(removeParentheses1); // Ticket #61 TEST_CASE(removeParentheses1); // Ticket #61
@ -4745,6 +4746,17 @@ private:
ASSERT_EQUALS(code, tokenizeAndStringify(code)); 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() { void simplifyFunctionParametersErrors() {
//same parameters... //same parameters...
tokenizeAndStringify("void foo(x, x)\n" tokenizeAndStringify("void foo(x, x)\n"