Fixed #1176 (void operator = check doesn't support struct)

This commit is contained in:
Robert Reif 2009-12-30 18:40:02 +01:00 committed by Daniel Marjamäki
parent d83131ca92
commit 3a46ef0487
2 changed files with 10 additions and 1 deletions

View File

@ -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();
}
}

View File

@ -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