Fixed #4824 (False positive: (warning) Member variable 'Foo::m_state' is not initialized in the constructor.)

This commit is contained in:
Lucas Manuel Rodriguez 2013-07-08 06:38:33 +02:00 committed by Daniel Marjamäki
parent 589614e791
commit d177c8fd03
2 changed files with 11 additions and 1 deletions

View File

@ -2500,7 +2500,7 @@ const Function* SymbolDatabase::findFunction(const Token *tok) const
}
// check for member function
else if (tok->strAt(-1) == ".") {
else if (Token::Match(tok->tokAt(-2), "!!this .")) {
if (Token::Match(tok->tokAt(-2), "%var% .")) {
const Token *tok1 = tok->tokAt(-2);

View File

@ -88,6 +88,7 @@ private:
TEST_CASE(initvar_nocopy1); // ticket #2474
TEST_CASE(initvar_nocopy2); // ticket #2484
TEST_CASE(initvar_nocopy3); // ticket #3611
TEST_CASE(initvar_with_member_function_this); // ticket #4824
TEST_CASE(initvar_destructor); // No variables need to be initialized in a destructor
TEST_CASE(initvar_func_ret_func_ptr); // ticket #4449
@ -1134,6 +1135,15 @@ private:
ASSERT_EQUALS("[test.cpp:4]: (warning, inconclusive) Member variable 'A::b' is not initialized in the constructor.\n", errout.str());
}
void initvar_with_member_function_this() {
check("struct Foo {\n"
" Foo(int m) { this->setMember(m); }\n"
" void setMember(int m) { member = m; }\n"
" int member;\n"
"};");
ASSERT_EQUALS("", errout.str());
}
void initvar_destructor() {
check("class Fred\n"
"{\n"