From 0c55d5cfa74fc09cda85037922dcca9386afd22e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sun, 9 Sep 2012 09:14:46 +0200 Subject: [PATCH] Fixed #4002 (syntax error for 'X( typedef, Y)') --- lib/tokenize.cpp | 12 ++++++------ test/testsimplifytokens.cpp | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index c3f2f5a29..2639ec3aa 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -527,6 +527,12 @@ void Tokenizer::simplifyTypedef() tok = tok->previous(); } + // Skip typedefs inside parentheses (#2453 and #4002) + if (tok->str() == "(" && tok->strAt(1) == "typedef") { + tok = tok->next(); + continue; + } + if (Token::Match(tok, "class|struct|namespace %any%") && (!tok->previous() || (tok->previous() && tok->previous()->str() != "enum"))) { isNamespace = (tok->str() == "namespace"); @@ -551,12 +557,6 @@ void Tokenizer::simplifyTypedef() } else if (tok->str() != "typedef") continue; - // check for syntax errors - if (tok->previous() && tok->previous()->str() == "(") { - syntaxError(tok); - continue; - } - // pull struct, union, enum or class definition out of typedef // use typedef name for unnamed struct, union, enum or class if (Token::Match(tok->next(), "const| struct|enum|union|class %type% {") || diff --git a/test/testsimplifytokens.cpp b/test/testsimplifytokens.cpp index 237f3e292..e3f369af1 100644 --- a/test/testsimplifytokens.cpp +++ b/test/testsimplifytokens.cpp @@ -5382,7 +5382,7 @@ private: const char code[] = "void f1(typedef int x) {}\n"; const std::string expected = "void f1 ( typedef int x ) { }"; ASSERT_EQUALS(expected, tok(code)); - ASSERT_EQUALS("[test.cpp:1]: (error) syntax error\n", errout.str()); + ASSERT_EQUALS("", errout.str()); } void simplifyTypedef77() { // ticket #2554