Merge branch 'master' of github.com:danmar/cppcheck

This commit is contained in:
Kimmo Varis 2010-06-28 20:47:54 +03:00
commit d5eaab05bc
2 changed files with 21 additions and 1 deletions

View File

@ -550,7 +550,7 @@ bool Tokenizer::duplicateTypedef(Token **tokPtr, const Token *name)
// look backwards // look backwards
if (Token::Match(tok->previous(), "typedef|}|>|*") || if (Token::Match(tok->previous(), "typedef|}|>|*") ||
(Token::Match(tok->previous(), "%type%") && (Token::Match(tok->previous(), "%type%") &&
(!Token::Match(tok->previous(), "return|new|const|friend|public|private|protected") && (!Token::Match(tok->previous(), "return|new|const|friend|public|private|protected|throw") &&
!Token::Match(tok->tokAt(-2), "friend class")))) !Token::Match(tok->tokAt(-2), "friend class"))))
{ {
// scan backwards for the end of the previous statement // scan backwards for the end of the previous statement

View File

@ -204,6 +204,7 @@ private:
TEST_CASE(simplifyTypedef51); TEST_CASE(simplifyTypedef51);
TEST_CASE(simplifyTypedef52); // ticket #1782 TEST_CASE(simplifyTypedef52); // ticket #1782
TEST_CASE(simplifyTypedef53); // ticket #1801 TEST_CASE(simplifyTypedef53); // ticket #1801
TEST_CASE(simplifyTypedef54); // ticket #1814
TEST_CASE(simplifyTypedefFunction1); TEST_CASE(simplifyTypedefFunction1);
TEST_CASE(simplifyTypedefFunction2); // ticket #1685 TEST_CASE(simplifyTypedefFunction2); // ticket #1685
@ -4206,6 +4207,25 @@ private:
} }
} }
void simplifyTypedef54() // ticket #1814
{
const char code[] = "void foo()\n"
"{\n"
" typedef std::basic_string<char, traits_type, allocator_type> string_type;\n"
" try\n"
" {\n"
" throw string_type(\"leak\");\n"
" }\n"
" catch (const string_type&)\n"
" {\n"
" pthread_exit (0);\n"
" }\n"
"}";
checkSimplifyTypedef(code);
ASSERT_EQUALS("", errout.str());
}
void simplifyTypedefFunction1() void simplifyTypedefFunction1()
{ {
{ {