fix #2675 (false positive: syntax error)

This commit is contained in:
Robert Reif 2011-03-24 22:26:42 -04:00
parent d643918761
commit fc258164cd
2 changed files with 12 additions and 1 deletions

View File

@ -1070,7 +1070,8 @@ void Tokenizer::simplifyTypedef()
typeStart = tok->next();
offset = 1;
while (Token::Match(tok->tokAt(offset), "const|signed|unsigned"))
while (Token::Match(tok->tokAt(offset), "const|signed|unsigned") ||
(tok->tokAt(offset + 1) && tok->tokAt(offset + 1)->isStandardType()))
offset++;
typeEnd = tok->tokAt(offset++);

View File

@ -251,6 +251,7 @@ private:
TEST_CASE(simplifyTypedef85); // ticket #2651
TEST_CASE(simplifyTypedef86); // ticket #2581
TEST_CASE(simplifyTypedef87); // ticket #2651
TEST_CASE(simplifyTypedef88); // ticket #2675
TEST_CASE(simplifyTypedefFunction1);
TEST_CASE(simplifyTypedefFunction2); // ticket #1685
@ -5070,6 +5071,15 @@ private:
ASSERT_EQUALS("", errout.str());
}
void simplifyTypedef88() // ticket #2675
{
const char code[] = "typedef short int (*x)(...);\n";
const char expected[] = ";";
checkSimplifyTypedef(code);
ASSERT_EQUALS(expected, sizeof_(code));
ASSERT_EQUALS("", errout.str());
}
void simplifyTypedefFunction1()
{
{