Fixed #4454 (False positive: class member (POD) not initialized (when initialized to 0 in initializer list))
This commit is contained in:
parent
9877b77291
commit
6e58ed3040
|
@ -365,8 +365,7 @@ void CheckClass::initializeVarList(const Function &func, std::list<const Functio
|
||||||
if (initList) {
|
if (initList) {
|
||||||
if (level == 0 && Token::Match(ftok, "%var% (")) {
|
if (level == 0 && Token::Match(ftok, "%var% (")) {
|
||||||
if (ftok->str() != func.name()) {
|
if (ftok->str() != func.name()) {
|
||||||
if (ftok->strAt(2) != ")")
|
initVar(ftok->str(), scope, usage);
|
||||||
initVar(ftok->str(), scope, usage);
|
|
||||||
} else { // c++11 delegate constructor
|
} else { // c++11 delegate constructor
|
||||||
const Function *member = symbolDatabase->findFunctionByNameAndArgsInScope(ftok, scope);
|
const Function *member = symbolDatabase->findFunctionByNameAndArgsInScope(ftok, scope);
|
||||||
// member function found
|
// member function found
|
||||||
|
|
|
@ -111,7 +111,6 @@ private:
|
||||||
TEST_CASE(uninitVar22); // ticket #3043
|
TEST_CASE(uninitVar22); // ticket #3043
|
||||||
TEST_CASE(uninitVar23); // ticket #3702
|
TEST_CASE(uninitVar23); // ticket #3702
|
||||||
TEST_CASE(uninitVar24); // ticket #3190
|
TEST_CASE(uninitVar24); // ticket #3190
|
||||||
TEST_CASE(uninitVar25); // ticket #4383
|
|
||||||
TEST_CASE(uninitVarEnum);
|
TEST_CASE(uninitVarEnum);
|
||||||
TEST_CASE(uninitVarStream);
|
TEST_CASE(uninitVarStream);
|
||||||
TEST_CASE(uninitVarTypedef);
|
TEST_CASE(uninitVarTypedef);
|
||||||
|
@ -1665,16 +1664,6 @@ private:
|
||||||
"[test.cpp:12]: (warning) Member variable 'Sub::b' is not initialized in the constructor.\n", errout.str());
|
"[test.cpp:12]: (warning) Member variable 'Sub::b' is not initialized in the constructor.\n", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void uninitVar25() { // ticket #4383
|
|
||||||
check("class Fred {\n"
|
|
||||||
" bool b;\n"
|
|
||||||
"public:\n"
|
|
||||||
" Fred() : b() { }\n"
|
|
||||||
"};\n");
|
|
||||||
|
|
||||||
ASSERT_EQUALS("[test.cpp:4]: (warning) Member variable 'Fred::b' is not initialized in the constructor.\n" , errout.str());
|
|
||||||
}
|
|
||||||
|
|
||||||
void uninitVarArray1() {
|
void uninitVarArray1() {
|
||||||
check("class John\n"
|
check("class John\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
|
|
Loading…
Reference in New Issue