From 04309f74f56816bc68906c8395561b57896bde74 Mon Sep 17 00:00:00 2001 From: Robert Reif Date: Wed, 20 Apr 2011 19:09:28 -0400 Subject: [PATCH] fix #2738 (syntax error on valid code) --- lib/tokenize.cpp | 2 +- test/testsimplifytokens.cpp | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 7ff42c9b6..4e965709f 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -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++; diff --git a/test/testsimplifytokens.cpp b/test/testsimplifytokens.cpp index a9d6c6961..1ade5fb0d 100644 --- a/test/testsimplifytokens.cpp +++ b/test/testsimplifytokens.cpp @@ -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() { {