This commit is contained in:
Sebastien Debrard 2011-03-15 23:04:41 +01:00
commit 57a6775a2d
2 changed files with 11 additions and 0 deletions

View File

@ -924,6 +924,7 @@ void CheckClass::checkReturnPtrThis(const Scope *scope, const Function *func, co
else if (!(Token::Match(tok->tokAt(1), "(| * this ;|=") || else if (!(Token::Match(tok->tokAt(1), "(| * this ;|=") ||
Token::Match(tok->tokAt(1), "(| * this +=") || Token::Match(tok->tokAt(1), "(| * this +=") ||
Token::simpleMatch(tok->tokAt(1), "operator= (") || Token::simpleMatch(tok->tokAt(1), "operator= (") ||
Token::simpleMatch(tok->tokAt(1), "this . operator= (") ||
(Token::Match(tok->tokAt(1), "%type% :: operator= (") && (Token::Match(tok->tokAt(1), "%type% :: operator= (") &&
tok->next()->str() == scope->className))) tok->next()->str() == scope->className)))
operatorEqRetRefThisError(func->token); operatorEqRetRefThisError(func->token);

View File

@ -452,6 +452,16 @@ private:
"A &A::operator =(int *other) { return (*this;) };\n" "A &A::operator =(int *other) { return (*this;) };\n"
"A &A::operator =(long *other) { return operator = (*(int *)other); };"); "A &A::operator =(long *other) { return operator = (*(int *)other); };");
ASSERT_EQUALS("", errout.str()); 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() void operatorEqRetRefThis4()