uninitialized const pointer member variables
This commit is contained in:
parent
1514e65464
commit
f96e2deb1a
|
@ -97,6 +97,12 @@ struct CheckClass::VAR *CheckClass::ClassChecking_GetVarList(const Token *tok1)
|
|||
varname = next->strAt(2);
|
||||
}
|
||||
|
||||
// Pointer?
|
||||
else if (Token::Match(next, "%type% %type% * %var% ;"))
|
||||
{
|
||||
varname = next->strAt(3);
|
||||
}
|
||||
|
||||
// If the varname was set in one of the two if-block above, create a entry for this variable..
|
||||
if (varname)
|
||||
{
|
||||
|
|
|
@ -68,6 +68,7 @@ private:
|
|||
TEST_CASE(initvar_same_classname); // BUG 2208157
|
||||
TEST_CASE(initvar_chained_assign); // BUG 2270433
|
||||
TEST_CASE(initvar_2constructors); // BUG 2270353
|
||||
TEST_CASE(initvar_constvar);
|
||||
|
||||
TEST_CASE(initvar_private_constructor); // BUG 2354171 - private constructor
|
||||
|
||||
|
@ -296,6 +297,20 @@ private:
|
|||
}
|
||||
|
||||
|
||||
void initvar_constvar()
|
||||
{
|
||||
check("class Fred\n"
|
||||
"{\n"
|
||||
"public:\n"
|
||||
" const char *s;\n"
|
||||
" Fred();\n"
|
||||
"};\n"
|
||||
"Fred::Fred()\n"
|
||||
"{ }");
|
||||
ASSERT_EQUALS(std::string("[test.cpp:7]: (style) Member variable not initialized in the constructor 'Fred::s'\n"), errout.str());
|
||||
}
|
||||
|
||||
|
||||
void initvar_private_constructor()
|
||||
{
|
||||
check("class Fred\n"
|
||||
|
|
Loading…
Reference in New Issue