Fixed #2382 (Catching exceptions by value instead of reference)

This commit is contained in:
Zachary Blair 2010-12-31 12:48:24 -08:00
parent 2da3fea1b8
commit 68700b3561
1 changed files with 2 additions and 3 deletions

View File

@ -319,8 +319,7 @@ void CheckOther::checkCatchExceptionByValue()
// Find a pass-by-value declaration in the catch(), excluding basic types
// e.g. catch (std::exception err)
const Token *tokType = Token::findmatch(tok, "%type% %var% )", endTok);
if (tokType &&
!Token::Match(tokType, "bool|char|double|enum|float|int|long|short|size_t|wchar_t"))
if (tokType && !tokType->isStandardType())
{
catchExceptionByValueError(tokType);
}
@ -2800,7 +2799,7 @@ void CheckOther::misusedScopeObjectError(const Token *tok, const std::string& va
void CheckOther::catchExceptionByValueError(const Token *tok)
{
reportError(tok, Severity::style,
"catchExceptionByStyle", "Exception should be caught by reference.\n"
"catchExceptionByValue", "Exception should be caught by reference.\n"
"The exception is caught as a value. It could be caught "
"as a (const) reference which is usually recommended in C++.");
}