This commit is contained in:
PKEuS 2012-05-22 02:27:21 -07:00
parent f5ef6f255e
commit f3f46b4861
2 changed files with 13 additions and 4 deletions

View File

@ -275,7 +275,7 @@ void CheckClass::initializeVarList(const Function &func, std::list<std::string>
ftok = ftok->next();
// Using the operator= function to initialize all variables..
if (Token::Match(ftok->next(), "return| * this =")) {
if (Token::Match(ftok->next(), "return| (| * this )| =")) {
assignAllVar(usage);
break;
}

View File

@ -291,7 +291,7 @@ private:
}
void initvar_operator_eq1() {
// Bug 2190376 - False positive, Uninitialized member variable with operator=
// Bug 2190376 and #3820 - False positive, Uninitialized member variable with operator=
check("struct Fred\n"
"{\n"
@ -305,8 +305,18 @@ private:
"\n"
" const Fred & operator=(const Fred &fred)\n"
" { i = fred.i; return *this; }\n"
"};\n");
"};");
ASSERT_EQUALS("", errout.str());
check("struct Fred {\n"
" int i;\n"
"\n"
" Fred(const Fred &fred)\n"
" { (*this) = fred; }\n"
"\n"
" const Fred & operator=(const Fred &fred)\n"
" { i = fred.i; return *this; }\n"
"};");
ASSERT_EQUALS("", errout.str());
check("struct A\n"
@ -322,7 +332,6 @@ private:
" int i;\n"
" int j;\n"
"};");
ASSERT_EQUALS("", errout.str());
}