fix #2738 (syntax error on valid code)

This commit is contained in:
Robert Reif 2011-04-20 19:09:28 -04:00
parent 79e5d2db15
commit 04309f74f5
2 changed files with 13 additions and 1 deletions

View File

@ -1071,7 +1071,7 @@ 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|struct|enum") ||
(tok->tokAt(offset + 1) && tok->tokAt(offset + 1)->isStandardType()))
offset++;

View File

@ -256,6 +256,7 @@ private:
TEST_CASE(simplifyTypedef90); // ticket #2718
TEST_CASE(simplifyTypedef91); // ticket #2716
TEST_CASE(simplifyTypedef92); // ticket #2736
TEST_CASE(simplifyTypedef93); // ticket #2738
TEST_CASE(simplifyTypedefFunction1);
TEST_CASE(simplifyTypedefFunction2); // ticket #1685
@ -5227,6 +5228,17 @@ private:
ASSERT_EQUALS("", errout.str());
}
void simplifyTypedef93() // ticket #2738 (syntax error)
{
const char code[] = "struct s { double x; };\n"
"typedef struct s (*binop) (struct s, struct s);\n";
const char expected[] = "struct s { double x ; } ;";
checkSimplifyTypedef(code);
ASSERT_EQUALS(expected, sizeof_(code));
ASSERT_EQUALS("", errout.str());
}
void simplifyTypedefFunction1()
{
{