Support use of 'this->' when checking operator=() return type
This commit is contained in:
parent
e1afd5eb09
commit
fa868e44ae
|
@ -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);
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue