Robert Reif: Fixed #1164 (only first void operator = found)
This commit is contained in:
parent
84ce6ba75a
commit
905533552d
|
@ -730,8 +730,10 @@ void CheckClass::noMemset()
|
|||
|
||||
void CheckClass::operatorEq()
|
||||
{
|
||||
const Token *tok = Token::findmatch(_tokenizer->tokens(), "void operator = (");
|
||||
if (tok)
|
||||
const Token *tok2 = _tokenizer->tokens();
|
||||
const Token *tok;
|
||||
|
||||
while ((tok = Token::findmatch(tok2, "void operator = (")))
|
||||
{
|
||||
const Token *tok1 = tok;
|
||||
while (tok1 && !Token::Match(tok1, "class %var%"))
|
||||
|
@ -745,6 +747,8 @@ void CheckClass::operatorEq()
|
|||
break;
|
||||
tok1 = tok1->previous();
|
||||
}
|
||||
|
||||
tok2 = tok->next();
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
|
|
@ -122,6 +122,19 @@ private:
|
|||
"};\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
checkOpertorEq("class A\n"
|
||||
"{\n"
|
||||
"public:\n"
|
||||
" void operator=(const& A);\n"
|
||||
"};\n"
|
||||
"class B\n"
|
||||
"{\n"
|
||||
"public:\n"
|
||||
" void operator=(const& B);\n"
|
||||
"};\n");
|
||||
ASSERT_EQUALS("[test.cpp:4]: (style) 'operator=' should return something\n"
|
||||
"[test.cpp:9]: (style) 'operator=' should return something\n", errout.str());
|
||||
|
||||
}
|
||||
|
||||
// Check that base classes have virtual destructors
|
||||
|
|
Loading…
Reference in New Issue