fix #2738 (syntax error on valid code)
This commit is contained in:
parent
79e5d2db15
commit
04309f74f5
|
@ -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++;
|
||||
|
||||
|
|
|
@ -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()
|
||||
{
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue