Fixed #1176 (void operator = check doesn't support struct)
This commit is contained in:
parent
d83131ca92
commit
3a46ef0487
|
@ -736,7 +736,7 @@ void CheckClass::operatorEq()
|
|||
while ((tok = Token::findmatch(tok2, "void operator = (")))
|
||||
{
|
||||
const Token *tok1 = tok;
|
||||
while (tok1 && !Token::Match(tok1, "class %var%"))
|
||||
while (tok1 && !Token::Match(tok1, "class|struct %var%"))
|
||||
{
|
||||
if (tok1->str() == "public:")
|
||||
{
|
||||
|
@ -748,6 +748,9 @@ void CheckClass::operatorEq()
|
|||
tok1 = tok1->previous();
|
||||
}
|
||||
|
||||
if (tok1 && Token::Match(tok1, "struct %var%"))
|
||||
operatorEqReturnError(tok);
|
||||
|
||||
tok2 = tok->next();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -135,6 +135,12 @@ private:
|
|||
ASSERT_EQUALS("[test.cpp:4]: (style) 'operator=' should return something\n"
|
||||
"[test.cpp:9]: (style) 'operator=' should return something\n", errout.str());
|
||||
|
||||
checkOpertorEq("struct A\n"
|
||||
"{\n"
|
||||
" void operator=(const& A);\n"
|
||||
"};\n");
|
||||
ASSERT_EQUALS("[test.cpp:3]: (style) 'operator=' should return something\n", errout.str());
|
||||
|
||||
}
|
||||
|
||||
// Check that base classes have virtual destructors
|
||||
|
|
Loading…
Reference in New Issue