fix #2403 (simplifyTypedef: array of function pointers) Internal error message

This commit is contained in:
Robert Reif 2011-02-22 22:11:17 -05:00
parent 458fc7454e
commit d1f7a8aca4
2 changed files with 22 additions and 0 deletions

View File

@ -886,6 +886,9 @@ static Token *processFunc(Token *tok2, bool inOperator)
tok2 = tok2->tokAt(4)->link()->next();
else if (Token::Match(tok2->next(), "* ( * %type% ("))
tok2 = tok2->tokAt(5)->link()->next();
else if (Token::Match(tok2->next(), "* [") &&
Token::simpleMatch(tok2->tokAt(2)->link(), "] ;"))
tok2 = tok2->next();
else
{
if (tok2->next()->str() == "(")

View File

@ -241,6 +241,7 @@ private:
TEST_CASE(simplifyTypedef79); // ticket #2348
TEST_CASE(simplifyTypedef80); // ticket #2587
TEST_CASE(simplifyTypedef81); // ticket #2603
TEST_CASE(simplifyTypedef82); // ticket #2403
TEST_CASE(simplifyTypedefFunction1);
TEST_CASE(simplifyTypedefFunction2); // ticket #1685
@ -4931,6 +4932,24 @@ private:
ASSERT_EQUALS("[test.cpp:1]: (error) syntax error\n", errout.str());
}
void simplifyTypedef82() // ticket #2403
{
checkSimplifyTypedef("class A {\n"
"public:\n"
" typedef int F(int idx);\n"
"};\n"
"class B {\n"
"public:\n"
" A::F ** f;\n"
"};\n"
"int main()\n"
"{\n"
" B * b = new B;\n"
" b->f = new A::F * [ 10 ];\n"
"}\n");
ASSERT_EQUALS("", errout.str());
}
void simplifyTypedefFunction1()
{
{