diff --git a/lib/checkclass.cpp b/lib/checkclass.cpp index e8d13cdff..d917ed8ce 100644 --- a/lib/checkclass.cpp +++ b/lib/checkclass.cpp @@ -924,6 +924,7 @@ void CheckClass::checkReturnPtrThis(const Scope *scope, const Function *func, co else if (!(Token::Match(tok->tokAt(1), "(| * this ;|=") || Token::Match(tok->tokAt(1), "(| * this +=") || Token::simpleMatch(tok->tokAt(1), "operator= (") || + Token::simpleMatch(tok->tokAt(1), "this . operator= (") || (Token::Match(tok->tokAt(1), "%type% :: operator= (") && tok->next()->str() == scope->className))) operatorEqRetRefThisError(func->token); diff --git a/test/testclass.cpp b/test/testclass.cpp index 2259a8071..45a9f22a7 100644 --- a/test/testclass.cpp +++ b/test/testclass.cpp @@ -452,6 +452,16 @@ private: "A &A::operator =(int *other) { return (*this;) };\n" "A &A::operator =(long *other) { return operator = (*(int *)other); };"); ASSERT_EQUALS("", errout.str()); + + checkOpertorEqRetRefThis( + "class A {\n" + "public:\n" + " A &operator =(int *other);\n" + " A &operator =(long *other);\n" + "};\n" + "A &A::operator =(int *other) { return (*this;) };\n" + "A &A::operator =(long *other) { return this->operator = (*(int *)other); };"); + ASSERT_EQUALS("", errout.str()); } void operatorEqRetRefThis4()