Uninitialized Member variable: Fixed FP when delegate constructor is used
This commit is contained in:
parent
fd9ca16e51
commit
8509159d1a
|
@ -598,8 +598,12 @@ void CheckClass::initializeVarList(const Function &func, std::list<const Functio
|
|||
initVar(ftok->varId(), scope, usage);
|
||||
} else { // c++11 delegate constructor
|
||||
const Function *member = ftok->function();
|
||||
// member function found
|
||||
if (member) {
|
||||
// member function not found => assume it initializes all members
|
||||
if (!member) {
|
||||
assignAllVar(usage);
|
||||
return;
|
||||
}
|
||||
|
||||
// recursive call
|
||||
// assume that all variables are initialized
|
||||
if (std::find(callstack.begin(), callstack.end(), member) != callstack.end()) {
|
||||
|
@ -621,7 +625,6 @@ void CheckClass::initializeVarList(const Function &func, std::list<const Functio
|
|||
assignAllVar(usage);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (level != 0 && Token::Match(ftok, "%name% =")) // assignment in the initializer: var(value = x)
|
||||
assignVar(ftok->varId(), scope, usage);
|
||||
|
||||
|
|
|
@ -96,6 +96,7 @@ private:
|
|||
TEST_CASE(initvar_staticvar);
|
||||
TEST_CASE(initvar_union);
|
||||
TEST_CASE(initvar_delegate); // ticket #4302
|
||||
TEST_CASE(initvar_delegate2);
|
||||
|
||||
TEST_CASE(initvar_private_constructor); // BUG 2354171 - private constructor
|
||||
TEST_CASE(initvar_copy_constructor); // ticket #1611
|
||||
|
@ -1138,6 +1139,29 @@ private:
|
|||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void initvar_delegate2() {
|
||||
check("class Foo {\n"
|
||||
"public:\n"
|
||||
" explicit Foo(const Bar bar);\n"
|
||||
" Foo(const std::string& id);\n"
|
||||
" virtual ~RtpSession() { }\n"
|
||||
"protected:\n"
|
||||
" bool a;\n"
|
||||
" uint16_t b;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"Foo::Foo(const Bar var)\n"
|
||||
" : Foo(bar->getId())\n"
|
||||
"{\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"Foo::Foo(const std::string& id)\n"
|
||||
" : a(true)\n"
|
||||
" , b(0)\n"
|
||||
"{\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void initvar_private_constructor() {
|
||||
settings.standards.cpp = Standards::CPP11;
|
||||
|
|
Loading…
Reference in New Issue