Fixed #2389 (mistakable warning from 'CheckClass::uninitVarError')

This commit is contained in:
Markus Elfring 2011-01-03 19:03:42 +01:00 committed by Daniel Marjamäki
parent d2714fefda
commit e459ed1de3
3 changed files with 58 additions and 58 deletions

View File

@ -173,7 +173,7 @@ void CheckClass::noConstructorError(const Token *tok, const std::string &classna
void CheckClass::uninitVarError(const Token *tok, const std::string &classname, const std::string &varname)
{
reportError(tok, Severity::warning, "uninitVar", "Member variable not initialized in the constructor '" + classname + "::" + varname + "'");
reportError(tok, Severity::warning, "uninitVar", "Member variable '" + classname + "::" + varname + "' is not initialised in the constructor.");
}
void CheckClass::operatorEqVarError(const Token *tok, const std::string &classname, const std::string &varname)

View File

@ -1537,7 +1537,7 @@ private:
" ECODES _code;\n"
"};\n");
ASSERT_EQUALS("[test.cpp:10]: (warning) Member variable not initialized in the constructor 'Fred::_code'\n", errout.str());
ASSERT_EQUALS("[test.cpp:10]: (warning) Member variable 'Fred::_code' is not initialised in the constructor.\n", errout.str());
checkUninitVar("class A{};\n"
@ -1549,7 +1549,7 @@ private:
"private:\n"
" float f;\n"
"};\n");
ASSERT_EQUALS("[test.cpp:6]: (warning) Member variable not initialized in the constructor 'B::f'\n", errout.str());
ASSERT_EQUALS("[test.cpp:6]: (warning) Member variable 'B::f' is not initialised in the constructor.\n", errout.str());
checkUninitVar("class C\n"
"{\n"
@ -1603,7 +1603,7 @@ private:
" };\n"
" Bar bars[2];\n"
"};\n");
ASSERT_EQUALS("[test.cpp:4]: (warning) Member variable not initialized in the constructor 'Foo::bars'\n", errout.str());
ASSERT_EQUALS("[test.cpp:4]: (warning) Member variable 'Foo::bars' is not initialised in the constructor.\n", errout.str());
}
void uninitVar4()
@ -1698,7 +1698,7 @@ private:
"{\n"
" SetMinSize( wxSize( 48,48 ) );\n"
"}\n");
ASSERT_EQUALS("[test.cpp:7]: (warning) Member variable not initialized in the constructor 'Prefs::xasd'\n", errout.str());
ASSERT_EQUALS("[test.cpp:7]: (warning) Member variable 'Prefs::xasd' is not initialised in the constructor.\n", errout.str());
}
void uninitVar10() // ticket #1993
@ -1711,7 +1711,7 @@ private:
" int var2;\n"
"};\n"
"A::A() : var1(0) { }\n");
ASSERT_EQUALS("[test.cpp:8]: (warning) Member variable not initialized in the constructor 'A::var2'\n", errout.str());
ASSERT_EQUALS("[test.cpp:8]: (warning) Member variable 'A::var2' is not initialised in the constructor.\n", errout.str());
}
void uninitVar11()
@ -1723,7 +1723,7 @@ private:
" int var;\n"
"};\n"
"A::A(int a) { }\n");
ASSERT_EQUALS("[test.cpp:7]: (warning) Member variable not initialized in the constructor 'A::var'\n", errout.str());
ASSERT_EQUALS("[test.cpp:7]: (warning) Member variable 'A::var' is not initialised in the constructor.\n", errout.str());
}
void uninitVar12() // ticket #2078
@ -1740,8 +1740,8 @@ private:
" {}\n"
" int x, y;\n"
"};\n");
ASSERT_EQUALS("[test.cpp:4]: (warning) Member variable not initialized in the constructor 'Point::x'\n"
"[test.cpp:4]: (warning) Member variable not initialized in the constructor 'Point::y'\n", errout.str());
ASSERT_EQUALS("[test.cpp:4]: (warning) Member variable 'Point::x' is not initialised in the constructor.\n"
"[test.cpp:4]: (warning) Member variable 'Point::y' is not initialised in the constructor.\n", errout.str());
}
void uninitVar13() // ticket #1195
@ -1753,7 +1753,7 @@ private:
" A()\n"
" {}\n"
"};\n");
ASSERT_EQUALS("[test.cpp:5]: (warning) Member variable not initialized in the constructor 'A::ints'\n", errout.str());
ASSERT_EQUALS("[test.cpp:5]: (warning) Member variable 'A::ints' is not initialised in the constructor.\n", errout.str());
}
void uninitVar14() // ticket #2149
@ -1769,7 +1769,7 @@ private:
"Foo::Foo()\n"
"{\n"
"}\n");
ASSERT_EQUALS("[test.cpp:8]: (warning) Member variable not initialized in the constructor 'Foo::mMember'\n", errout.str());
ASSERT_EQUALS("[test.cpp:8]: (warning) Member variable 'Foo::mMember' is not initialised in the constructor.\n", errout.str());
// single namespace
checkUninitVar("namespace Output\n"
@ -1785,7 +1785,7 @@ private:
" {\n"
" }\n"
"}\n");
ASSERT_EQUALS("[test.cpp:10]: (warning) Member variable not initialized in the constructor 'Foo::mMember'\n", errout.str());
ASSERT_EQUALS("[test.cpp:10]: (warning) Member variable 'Foo::mMember' is not initialised in the constructor.\n", errout.str());
// constructor outside namespace
checkUninitVar("namespace Output\n"
@ -1817,7 +1817,7 @@ private:
"Output::Foo::Foo()\n"
"{\n"
"}\n");
ASSERT_EQUALS("[test.cpp:11]: (warning) Member variable not initialized in the constructor 'Foo::mMember'\n", errout.str());
ASSERT_EQUALS("[test.cpp:11]: (warning) Member variable 'Foo::mMember' is not initialised in the constructor.\n", errout.str());
// constructor in separate namespace
checkUninitVar("namespace Output\n"
@ -1836,7 +1836,7 @@ private:
" {\n"
" }\n"
"}\n");
ASSERT_EQUALS("[test.cpp:13]: (warning) Member variable not initialized in the constructor 'Foo::mMember'\n", errout.str());
ASSERT_EQUALS("[test.cpp:13]: (warning) Member variable 'Foo::mMember' is not initialised in the constructor.\n", errout.str());
// constructor in different separate namespace
checkUninitVar("namespace Output\n"
@ -1896,7 +1896,7 @@ private:
" }\n"
" }\n"
"}\n");
ASSERT_EQUALS("[test.cpp:15]: (warning) Member variable not initialized in the constructor 'Foo::mMember'\n", errout.str());
ASSERT_EQUALS("[test.cpp:15]: (warning) Member variable 'Foo::mMember' is not initialised in the constructor.\n", errout.str());
// constructor in nested different separate namespace
checkUninitVar("namespace A\n"
@ -1989,7 +1989,7 @@ private:
" {\n"
" }\n"
"};\n");
ASSERT_EQUALS("[test.cpp:10]: (warning) Member variable not initialized in the constructor 'Bar::foo'\n", errout.str());
ASSERT_EQUALS("[test.cpp:10]: (warning) Member variable 'Bar::foo' is not initialised in the constructor.\n", errout.str());
}
void uninitVar17()
@ -2021,7 +2021,7 @@ private:
" {\n"
" }\n"
"};\n");
ASSERT_EQUALS("[test.cpp:9]: (warning) Member variable not initialized in the constructor 'Bar::foo'\n", errout.str());
ASSERT_EQUALS("[test.cpp:9]: (warning) Member variable 'Bar::foo' is not initialised in the constructor.\n", errout.str());
}
void uninitVarArray1()
@ -2034,7 +2034,7 @@ private:
"private:\n"
" char name[255];\n"
"};\n");
ASSERT_EQUALS("[test.cpp:4]: (warning) Member variable not initialized in the constructor 'John::name'\n", errout.str());
ASSERT_EQUALS("[test.cpp:4]: (warning) Member variable 'John::name' is not initialised in the constructor.\n", errout.str());
checkUninitVar("class John\n"
"{\n"
@ -2081,7 +2081,7 @@ private:
" John() { }\n"
" A *a[5];\n"
"};\n");
ASSERT_EQUALS("[test.cpp:5]: (warning) Member variable not initialized in the constructor 'John::a'\n", errout.str());
ASSERT_EQUALS("[test.cpp:5]: (warning) Member variable 'John::a' is not initialised in the constructor.\n", errout.str());
}
void uninitVarArray2()
@ -2200,7 +2200,7 @@ private:
" A() {\n"
" }\n"
"};\n");
ASSERT_EQUALS("[test.cpp:10]: (warning) Member variable not initialized in the constructor 'A::b'\n", errout.str());
ASSERT_EQUALS("[test.cpp:10]: (warning) Member variable 'A::b' is not initialised in the constructor.\n", errout.str());
checkUninitVar("class A\n"
"{\n"
@ -2233,7 +2233,7 @@ private:
" Fred()\n"
" { }\n"
"};\n");
ASSERT_EQUALS("[test.cpp:11]: (warning) Member variable not initialized in the constructor 'Fred::p'\n", errout.str());
ASSERT_EQUALS("[test.cpp:11]: (warning) Member variable 'Fred::p' is not initialised in the constructor.\n", errout.str());
checkUninitVar("struct POINT\n"
"{\n"
@ -2300,7 +2300,7 @@ private:
"private:\n"
" int i;\n"
"};\n");
ASSERT_EQUALS("[test.cpp:4]: (warning) Member variable not initialized in the constructor 'Fred::i'\n", errout.str());
ASSERT_EQUALS("[test.cpp:4]: (warning) Member variable 'Fred::i' is not initialised in the constructor.\n", errout.str());
// Unknown non-member function
checkUninitVar("class Fred\n"
@ -2310,7 +2310,7 @@ private:
"private:\n"
" int i;\n"
"};\n");
ASSERT_EQUALS("[test.cpp:4]: (warning) Member variable not initialized in the constructor 'Fred::i'\n", errout.str());
ASSERT_EQUALS("[test.cpp:4]: (warning) Member variable 'Fred::i' is not initialised in the constructor.\n", errout.str());
// Unknown non-member function
checkUninitVar("class ABC { };\n"
@ -2321,7 +2321,7 @@ private:
"private:\n"
" int i;\n"
"};\n");
ASSERT_EQUALS("[test.cpp:5]: (warning) Member variable not initialized in the constructor 'Fred::i'\n", errout.str());
ASSERT_EQUALS("[test.cpp:5]: (warning) Member variable 'Fred::i' is not initialised in the constructor.\n", errout.str());
}
@ -2336,7 +2336,7 @@ private:
" unsigned int i;\n"
"};\n");
ASSERT_EQUALS("[test.cpp:5]: (warning) Member variable not initialized in the constructor 'Fred::i'\n", errout.str());
ASSERT_EQUALS("[test.cpp:5]: (warning) Member variable 'Fred::i' is not initialised in the constructor.\n", errout.str());
}
void uninitVarStream()
@ -2402,7 +2402,7 @@ private:
" Foo(int _i) { }\n"
"};\n");
ASSERT_EQUALS("[test.cpp:7]: (warning) Member variable not initialized in the constructor 'Foo::foo'\n", errout.str());
ASSERT_EQUALS("[test.cpp:7]: (warning) Member variable 'Foo::foo' is not initialised in the constructor.\n", errout.str());
}
@ -2453,7 +2453,7 @@ private:
" Fred() { }\n"
"};\n"
"#endfile\n");
ASSERT_EQUALS("[fred.h:6]: (warning) Member variable not initialized in the constructor 'Fred::i'\n", errout.str());
ASSERT_EQUALS("[fred.h:6]: (warning) Member variable 'Fred::i' is not initialised in the constructor.\n", errout.str());
}
void uninitVarHeader3()
@ -2467,7 +2467,7 @@ private:
" Fred() { }\n"
"};\n"
"#endfile\n");
ASSERT_EQUALS("[fred.h:6]: (warning) Member variable not initialized in the constructor 'Fred::i'\n", errout.str());
ASSERT_EQUALS("[fred.h:6]: (warning) Member variable 'Fred::i' is not initialised in the constructor.\n", errout.str());
}
// Borland C++: No FP for published pointers - they are automatically initialized
@ -2588,8 +2588,8 @@ private:
"A::B::B()\n"
"{\n"
"}\n");
ASSERT_EQUALS("[test.cpp:18]: (warning) Member variable not initialized in the constructor 'B::j'\n"
"[test.cpp:22]: (warning) Member variable not initialized in the constructor 'B::i'\n", errout.str());
ASSERT_EQUALS("[test.cpp:18]: (warning) Member variable 'B::j' is not initialised in the constructor.\n"
"[test.cpp:22]: (warning) Member variable 'B::i' is not initialised in the constructor.\n", errout.str());
// Ticket #1700
checkUninitVar("namespace n1\n"
@ -2631,7 +2631,7 @@ private:
" Foo() { }\n"
"};\n"
"}\n");
ASSERT_EQUALS("[test.cpp:11]: (warning) Member variable not initialized in the constructor 'Foo::i'\n", errout.str());
ASSERT_EQUALS("[test.cpp:11]: (warning) Member variable 'Foo::i' is not initialised in the constructor.\n", errout.str());
checkUninitVar("namespace n1\n"
"{\n"

View File

@ -138,7 +138,7 @@ private:
" Fred() { }\n"
" int i;\n"
"};\n");
ASSERT_EQUALS("[test.cpp:4]: (warning) Member variable not initialized in the constructor 'Fred::i'\n", errout.str());
ASSERT_EQUALS("[test.cpp:4]: (warning) Member variable 'Fred::i' is not initialised in the constructor.\n", errout.str());
check("struct Fred\n"
"{\n"
@ -159,7 +159,7 @@ private:
" Fred() { }\n"
" int i;\n"
"};\n");
ASSERT_EQUALS("[test.cpp:3]: (warning) Member variable not initialized in the constructor 'Fred::i'\n", errout.str());
ASSERT_EQUALS("[test.cpp:3]: (warning) Member variable 'Fred::i' is not initialised in the constructor.\n", errout.str());
}
@ -193,7 +193,7 @@ private:
"};\n"
"Fred::Fred()\n"
"{ }\n");
ASSERT_EQUALS("[test.cpp:7]: (warning) Member variable not initialized in the constructor 'Fred::i'\n", errout.str());
ASSERT_EQUALS("[test.cpp:7]: (warning) Member variable 'Fred::i' is not initialised in the constructor.\n", errout.str());
check("struct Fred\n"
"{\n"
@ -220,7 +220,7 @@ private:
"};\n"
"Fred::Fred()\n"
"{ }\n");
ASSERT_EQUALS("[test.cpp:6]: (warning) Member variable not initialized in the constructor 'Fred::i'\n", errout.str());
ASSERT_EQUALS("[test.cpp:6]: (warning) Member variable 'Fred::i' is not initialised in the constructor.\n", errout.str());
}
@ -239,7 +239,7 @@ private:
"{\n"
" i = _i;\n"
"}\n");
ASSERT_EQUALS("[test.cpp:8]: (warning) Member variable not initialized in the constructor 'Fred::i'\n", errout.str());
ASSERT_EQUALS("[test.cpp:8]: (warning) Member variable 'Fred::i' is not initialised in the constructor.\n", errout.str());
check("struct Fred\n"
"{\n"
@ -253,7 +253,7 @@ private:
"{\n"
" i = _i;\n"
"}\n");
ASSERT_EQUALS("[test.cpp:7]: (warning) Member variable not initialized in the constructor 'Fred::i'\n", errout.str());
ASSERT_EQUALS("[test.cpp:7]: (warning) Member variable 'Fred::i' is not initialised in the constructor.\n", errout.str());
}
@ -598,8 +598,8 @@ private:
" }\n"
"};\n");
ASSERT_EQUALS("[test.cpp:7]: (warning) Member variable not initialized in the constructor 'Fred::a'\n"
"[test.cpp:16]: (warning) Member variable not initialized in the constructor 'Fred::b'\n", errout.str());
ASSERT_EQUALS("[test.cpp:7]: (warning) Member variable 'Fred::a' is not initialised in the constructor.\n"
"[test.cpp:16]: (warning) Member variable 'Fred::b' is not initialised in the constructor.\n", errout.str());
}
void initvar_chained_assign()
@ -732,7 +732,7 @@ private:
"};\n"
"Fred::Fred()\n"
"{ }");
ASSERT_EQUALS("[test.cpp:7]: (warning) Member variable not initialized in the constructor 'Fred::s'\n", errout.str());
ASSERT_EQUALS("[test.cpp:7]: (warning) Member variable 'Fred::s' is not initialised in the constructor.\n", errout.str());
check("struct Fred\n"
"{\n"
@ -759,7 +759,7 @@ private:
"};\n"
"Fred::Fred()\n"
"{ }");
ASSERT_EQUALS("[test.cpp:6]: (warning) Member variable not initialized in the constructor 'Fred::s'\n", errout.str());
ASSERT_EQUALS("[test.cpp:6]: (warning) Member variable 'Fred::s' is not initialised in the constructor.\n", errout.str());
}
@ -799,7 +799,7 @@ private:
" Fred() { };\n"
" Fred(const Fred &) { };\n"
"};");
ASSERT_EQUALS("[test.cpp:7]: (warning) Member variable not initialized in the constructor 'Fred::var'\n", errout.str());
ASSERT_EQUALS("[test.cpp:7]: (warning) Member variable 'Fred::var' is not initialised in the constructor.\n", errout.str());
check("class Fred\n"
"{\n"
@ -811,7 +811,7 @@ private:
"};\n"
"Fred::Fred() { };\n"
"Fred::Fred(const Fred &) { };\n");
ASSERT_EQUALS("[test.cpp:10]: (warning) Member variable not initialized in the constructor 'Fred::var'\n", errout.str());
ASSERT_EQUALS("[test.cpp:10]: (warning) Member variable 'Fred::var' is not initialised in the constructor.\n", errout.str());
}
void initvar_nested_constructor() // ticket #1375
@ -839,11 +839,11 @@ private:
"A::B::B(int x){}\n"
"A::B::C::C(int y){}\n"
"A::B::C::D::D(int z){}\n");
ASSERT_EQUALS("[test.cpp:20]: (warning) Member variable not initialized in the constructor 'A::a'\n"
"[test.cpp:20]: (warning) Member variable not initialized in the constructor 'A::b'\n"
"[test.cpp:21]: (warning) Member variable not initialized in the constructor 'B::b'\n"
"[test.cpp:22]: (warning) Member variable not initialized in the constructor 'C::c'\n"
"[test.cpp:23]: (warning) Member variable not initialized in the constructor 'D::d'\n", errout.str());
ASSERT_EQUALS("[test.cpp:20]: (warning) Member variable 'A::a' is not initialised in the constructor.\n"
"[test.cpp:20]: (warning) Member variable 'A::b' is not initialised in the constructor.\n"
"[test.cpp:21]: (warning) Member variable 'B::b' is not initialised in the constructor.\n"
"[test.cpp:22]: (warning) Member variable 'C::c' is not initialised in the constructor.\n"
"[test.cpp:23]: (warning) Member variable 'D::d' is not initialised in the constructor.\n", errout.str());
check("class A {\n"
"public:\n"
@ -868,11 +868,11 @@ private:
"A::B::B(int x){}\n"
"A::B::C::C(int y){}\n"
"A::B::C::D::D(const A::B::C::D & d){}\n");
ASSERT_EQUALS("[test.cpp:20]: (warning) Member variable not initialized in the constructor 'A::a'\n"
"[test.cpp:20]: (warning) Member variable not initialized in the constructor 'A::b'\n"
"[test.cpp:21]: (warning) Member variable not initialized in the constructor 'B::b'\n"
"[test.cpp:22]: (warning) Member variable not initialized in the constructor 'C::c'\n"
"[test.cpp:23]: (warning) Member variable not initialized in the constructor 'D::d'\n", errout.str());
ASSERT_EQUALS("[test.cpp:20]: (warning) Member variable 'A::a' is not initialised in the constructor.\n"
"[test.cpp:20]: (warning) Member variable 'A::b' is not initialised in the constructor.\n"
"[test.cpp:21]: (warning) Member variable 'B::b' is not initialised in the constructor.\n"
"[test.cpp:22]: (warning) Member variable 'C::c' is not initialised in the constructor.\n"
"[test.cpp:23]: (warning) Member variable 'D::d' is not initialised in the constructor.\n", errout.str());
check("class A {\n"
"public:\n"
@ -898,11 +898,11 @@ private:
"A::B::B(int x){}\n"
"A::B::C::C(int y){}\n"
"A::B::C::D::D(const A::B::C::D::E & e){}\n");
ASSERT_EQUALS("[test.cpp:21]: (warning) Member variable not initialized in the constructor 'A::a'\n"
"[test.cpp:21]: (warning) Member variable not initialized in the constructor 'A::b'\n"
"[test.cpp:22]: (warning) Member variable not initialized in the constructor 'B::b'\n"
"[test.cpp:23]: (warning) Member variable not initialized in the constructor 'C::c'\n"
"[test.cpp:24]: (warning) Member variable not initialized in the constructor 'D::d'\n", errout.str());
ASSERT_EQUALS("[test.cpp:21]: (warning) Member variable 'A::a' is not initialised in the constructor.\n"
"[test.cpp:21]: (warning) Member variable 'A::b' is not initialised in the constructor.\n"
"[test.cpp:22]: (warning) Member variable 'B::b' is not initialised in the constructor.\n"
"[test.cpp:23]: (warning) Member variable 'C::c' is not initialised in the constructor.\n"
"[test.cpp:24]: (warning) Member variable 'D::d' is not initialised in the constructor.\n", errout.str());
}
void initvar_destructor()