Fixed #2078 (false negative: member variable not intialized)
This commit is contained in:
parent
a3367874d9
commit
14f12e0647
|
@ -964,7 +964,7 @@ void CheckClass::SpaceInfo::initializeVarList(const Func &func, std::list<std::s
|
||||||
std::list<Func>::const_iterator it;
|
std::list<Func>::const_iterator it;
|
||||||
for (it = functionList.begin(); it != functionList.end(); ++it)
|
for (it = functionList.begin(); it != functionList.end(); ++it)
|
||||||
{
|
{
|
||||||
if (ftok->str() == it->tokenDef->str())
|
if (ftok->str() == it->tokenDef->str() && it->type != Func::Constructor)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,6 +55,7 @@ private:
|
||||||
TEST_CASE(uninitVar9); // ticket #1730
|
TEST_CASE(uninitVar9); // ticket #1730
|
||||||
TEST_CASE(uninitVar10); // ticket #1993
|
TEST_CASE(uninitVar10); // ticket #1993
|
||||||
TEST_CASE(uninitVar11);
|
TEST_CASE(uninitVar11);
|
||||||
|
TEST_CASE(uninitVar12); // ticket #2078
|
||||||
TEST_CASE(uninitVarEnum);
|
TEST_CASE(uninitVarEnum);
|
||||||
TEST_CASE(uninitVarStream);
|
TEST_CASE(uninitVarStream);
|
||||||
TEST_CASE(uninitVarTypedef);
|
TEST_CASE(uninitVarTypedef);
|
||||||
|
@ -1677,6 +1678,24 @@ private:
|
||||||
ASSERT_EQUALS("[test.cpp:7]: (style) Member variable not initialized in the constructor 'A::var'\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:7]: (style) Member variable not initialized in the constructor 'A::var'\n", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void uninitVar12() // ticket #2078
|
||||||
|
{
|
||||||
|
checkUninitVar("class Point\n"
|
||||||
|
"{\n"
|
||||||
|
"public:\n"
|
||||||
|
" Point()\n"
|
||||||
|
" {\n"
|
||||||
|
" Point(0, 0);\n"
|
||||||
|
" }\n"
|
||||||
|
" Point(int x, int y)\n"
|
||||||
|
" : x(x), y(y)\n"
|
||||||
|
" {}\n"
|
||||||
|
" int x, y;\n"
|
||||||
|
"};\n");
|
||||||
|
ASSERT_EQUALS("[test.cpp:4]: (style) Member variable not initialized in the constructor 'Point::x'\n"
|
||||||
|
"[test.cpp:4]: (style) Member variable not initialized in the constructor 'Point::y'\n", errout.str());
|
||||||
|
}
|
||||||
|
|
||||||
void uninitVarArray1()
|
void uninitVarArray1()
|
||||||
{
|
{
|
||||||
checkUninitVar("class John\n"
|
checkUninitVar("class John\n"
|
||||||
|
|
Loading…
Reference in New Issue