Fixed ticket #3616 (segmentation fault of cppcheck).

This commit is contained in:
Edoardo Prezioso 2012-02-18 17:57:50 +01:00
parent a118f82ca7
commit d7a918e549
2 changed files with 9 additions and 0 deletions

View File

@ -1374,6 +1374,8 @@ void Tokenizer::simplifyTypedef()
// check for member functions
else if (Token::Match(tok2, ") const| {")) {
const Token *func = tok2->link()->previous();
if (!func)
continue;
/** @todo add support for multi-token operators */
if (func->previous()->str() == "operator")

View File

@ -281,6 +281,7 @@ private:
TEST_CASE(simplifyTypedef102); // ticket #3004
TEST_CASE(simplifyTypedef103); // ticket #3007
TEST_CASE(simplifyTypedef104); // ticket #3070
TEST_CASE(simplifyTypedef105); // ticket #3616
TEST_CASE(simplifyTypedefFunction1);
TEST_CASE(simplifyTypedefFunction2); // ticket #1685
@ -5732,6 +5733,12 @@ private:
ASSERT_EQUALS("", errout.str());
}
void simplifyTypedef105() { // ticket #3616 (segmentation fault)
const char code[] = "( int typedef char x; ){}\n";
sizeof_(code);
ASSERT_EQUALS("", errout.str());
}
void simplifyTypedefFunction1() {
{
const char code[] = "typedef void (*my_func)();\n"