Check Class: Removed the 'operator= should not return a const reference'

This commit is contained in:
Daniel Marjamäki 2010-09-18 20:05:34 +02:00
parent 6ba5385878
commit a7cf68b9ef
3 changed files with 0 additions and 20 deletions

View File

@ -1515,8 +1515,6 @@ void CheckClass::operatorEq()
{
if (it->token->strAt(-2) == "void")
operatorEqReturnError(it->token->tokAt(-2));
else if (Token::Match(it->token->tokAt(-4), "const %type% &"))
operatorEqReturnConstError(it->token->tokAt(-4));
}
}
}
@ -2261,11 +2259,6 @@ void CheckClass::operatorEqReturnError(const Token *tok)
reportError(tok, Severity::style, "operatorEq", "'operator=' should return something");
}
void CheckClass::operatorEqReturnConstError(const Token *tok)
{
reportError(tok, Severity::style, "operatorEqReturnConst", "'operator=' should not return a const reference");
}
void CheckClass::virtualDestructorError(const Token *tok, const std::string &Base, const std::string &Derived)
{
reportError(tok, Severity::error, "virtualDestructor", "Class " + Base + " which is inherited by class " + Derived + " does not have a virtual destructor");

View File

@ -320,7 +320,6 @@ private:
void memsetClassError(const Token *tok, const std::string &memfunc);
void memsetStructError(const Token *tok, const std::string &memfunc, const std::string &classname);
void operatorEqReturnError(const Token *tok);
void operatorEqReturnConstError(const Token *tok);
void virtualDestructorError(const Token *tok, const std::string &Base, const std::string &Derived);
void thisSubtractionError(const Token *tok);
void operatorEqRetRefThisError(const Token *tok);
@ -338,7 +337,6 @@ private:
memsetClassError(0, "memfunc");
memsetStructError(0, "memfunc", "classname");
operatorEqReturnError(0);
operatorEqReturnConstError(0);
//virtualDestructorError(0, "Base", "Derived");
thisSubtractionError(0);
operatorEqRetRefThisError(0);

View File

@ -88,7 +88,6 @@ private:
TEST_CASE(noConstructor5);
TEST_CASE(operatorEq1);
TEST_CASE(operatorEq2);
TEST_CASE(operatorEqRetRefThis1);
TEST_CASE(operatorEqRetRefThis2); // ticket #1323
TEST_CASE(operatorEqRetRefThis3); // ticket #1405
@ -232,16 +231,6 @@ private:
ASSERT_EQUALS("[test.cpp:3]: (style) 'operator=' should return something\n", errout.str());
}
void operatorEq2()
{
checkOpertorEq("class A\n"
"{\n"
"public:\n"
" const A& operator=(const A&);\n"
"};\n");
ASSERT_EQUALS("[test.cpp:4]: (style) 'operator=' should not return a const reference\n", errout.str());
}
// Check that operator Equal returns reference to this
void checkOpertorEqRetRefThis(const char code[])
{