Fixed #7755 (false positive: member variable is not initialized in the constructor)
This commit is contained in:
parent
4216b26b8c
commit
0de47f709e
|
@ -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);
|
||||
|
|
|
@ -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() {
|
||||
|
|
Loading…
Reference in New Issue