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()
|
void CheckClass::operatorEq()
|
||||||
{
|
{
|
||||||
const Token *tok = Token::findmatch(_tokenizer->tokens(), "void operator = (");
|
const Token *tok2 = _tokenizer->tokens();
|
||||||
if (tok)
|
const Token *tok;
|
||||||
|
|
||||||
|
while ((tok = Token::findmatch(tok2, "void operator = (")))
|
||||||
{
|
{
|
||||||
const Token *tok1 = tok;
|
const Token *tok1 = tok;
|
||||||
while (tok1 && !Token::Match(tok1, "class %var%"))
|
while (tok1 && !Token::Match(tok1, "class %var%"))
|
||||||
|
@ -745,6 +747,8 @@ void CheckClass::operatorEq()
|
||||||
break;
|
break;
|
||||||
tok1 = tok1->previous();
|
tok1 = tok1->previous();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tok2 = tok->next();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
|
@ -122,6 +122,19 @@ private:
|
||||||
"};\n");
|
"};\n");
|
||||||
ASSERT_EQUALS("", errout.str());
|
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
|
// Check that base classes have virtual destructors
|
||||||
|
|
Loading…
Reference in New Issue