Fixed #7755 (false positive: member variable is not initialized in the constructor)

This commit is contained in:
Harald Scheidl 2016-10-16 22:21:33 +02:00 committed by Daniel Marjamäki
parent 4216b26b8c
commit 0de47f709e
2 changed files with 11 additions and 1 deletions

View File

@ -633,7 +633,7 @@ void CheckClass::initializeVarList(const Function &func, std::list<const Functio
if (ftok->str() == "::")
ftok = ftok->next();
int offsetToMember = 4;
if (ftok->tokAt(ftok->strAt(2) == "&"))
if (ftok->strAt(2) == "&")
++offsetToMember;
assignVar(ftok->tokAt(offsetToMember)->varId(), scope, usage);
ftok = ftok->linkAt(1);

View File

@ -2849,6 +2849,16 @@ private:
" return foobar.foo.f + foobar.bar.b;\n"
"}");
ASSERT_EQUALS("[test.cpp:4]: (warning) Member variable 'FooBar::bar' is not initialized in the constructor.\n", errout.str());
// #7755
check("struct A {\n"
" A() {\n"
" memset(this->data, 0, 42);\n"
" }\n"
" char data[42];\n"
"};");
ASSERT_EQUALS("", errout.str());
}
void privateCtor1() {