Check 'operator=()'

This commit is contained in:
Daniel Marjamäki 2007-05-09 18:10:10 +00:00
parent 36a9f22b62
commit 2c697c6252
1 changed files with 23 additions and 1 deletions

View File

@ -29,6 +29,7 @@ void Tokenize(const char FileName[]);
void CheckConstructors();
void CheckUnusedPrivateFunctions();
void CheckMemset();
void CheckOperatorEq1(); // Warning upon "void operator=(.."
// Function
void CheckMovableVariableDeclaration();
@ -86,7 +87,11 @@ static void CppCheck(const char FileName[])
// This function can do dangerous things if used wrong.
CheckMemset();
WarningHeaderWithImplementation();
CheckOperatorEq1();
// Found implementation in header
// Since this is not a bug I am not enabling it right now
//WarningHeaderWithImplementation();
// Warning upon c-style pointer casts
WarningOldStylePointerCast();
@ -868,6 +873,23 @@ void CheckMemset()
//---------------------------------------------------------------------------
// Class: "void operator=("
//---------------------------------------------------------------------------
void CheckOperatorEq1()
{
const char *pattern[] = {"void", "operator", "=", "(", NULL};
if (TOKEN *tok = findtoken(tokens,pattern))
{
std::ostringstream ostr;
ostr << FileLine(tok) << ": 'operator=' should return something";
ReportErr(ostr.str());
}
}
//---------------------------------------------------------------------------
// HEADERS - No implementation in a header