fix #3043 (False Positive - Member variable 'ProgramRecPriorityInfo::profile' is not assigned a value in 'ProgramRecPriorityInfo::operator=')
This commit is contained in:
parent
423a1ff64e
commit
1d7ab77251
|
@ -340,6 +340,10 @@ void CheckClass::initializeVarList(const Function &func, std::list<std::string>
|
|||
// Goto the first token in this statement..
|
||||
ftok = ftok->next();
|
||||
|
||||
// skip "return"
|
||||
if (ftok->str() == "return")
|
||||
ftok = ftok->next();
|
||||
|
||||
// Skip "( * this )"
|
||||
if (Token::simpleMatch(ftok, "( * this ) ."))
|
||||
{
|
||||
|
|
|
@ -66,6 +66,7 @@ private:
|
|||
TEST_CASE(uninitVar19); // ticket #2792
|
||||
TEST_CASE(uninitVar20); // ticket #2867
|
||||
TEST_CASE(uninitVar21); // ticket #2947
|
||||
TEST_CASE(uninitVar22); // ticket #3043
|
||||
TEST_CASE(uninitVarEnum);
|
||||
TEST_CASE(uninitVarStream);
|
||||
TEST_CASE(uninitVarTypedef);
|
||||
|
@ -2263,6 +2264,38 @@ private:
|
|||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void uninitVar22() // ticket #3043
|
||||
{
|
||||
checkUninitVar("class Fred {\n"
|
||||
" public:\n"
|
||||
" Fred & operator=(const Fred &);\n"
|
||||
" virtual Fred & clone(const Fred & other);\n"
|
||||
" int x;\n"
|
||||
"};\n"
|
||||
"Fred & Fred::operator=(const Fred & other) {\n"
|
||||
" return clone(other);\n"
|
||||
"}\n"
|
||||
"Fred & Fred::clone(const Fred & other) {\n"
|
||||
" x = 0;\n"
|
||||
" return *this;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
checkUninitVar("class Fred {\n"
|
||||
" public:\n"
|
||||
" Fred & operator=(const Fred &);\n"
|
||||
" virtual Fred & clone(const Fred & other);\n"
|
||||
" int x;\n"
|
||||
"};\n"
|
||||
"Fred & Fred::operator=(const Fred & other) {\n"
|
||||
" return clone(other);\n"
|
||||
"}\n"
|
||||
"Fred & Fred::clone(const Fred & other) {\n"
|
||||
" return *this;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("[test.cpp:7]: (warning) Member variable 'Fred::x' is not assigned a value in 'Fred::operator='\n", errout.str());
|
||||
}
|
||||
|
||||
void uninitVarArray1()
|
||||
{
|
||||
checkUninitVar("class John\n"
|
||||
|
|
Loading…
Reference in New Issue