diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 3ab5a4dd1..e9fa933ea 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -721,7 +721,7 @@ bool Tokenizer::duplicateTypedef(Token **tokPtr, const Token *name, const Token duplicateTypedefError(*tokPtr, name, "Struct"); return true; } - else if (tok->next()->str() == ")") + else if (Token::Match(tok->next(), ")|*")) { return true; } diff --git a/test/testsimplifytokens.cpp b/test/testsimplifytokens.cpp index 2e855bb48..3e322b922 100644 --- a/test/testsimplifytokens.cpp +++ b/test/testsimplifytokens.cpp @@ -267,6 +267,7 @@ private: TEST_CASE(simplifyTypedef99); // ticket #2999 TEST_CASE(simplifyTypedef100); // ticket #3000 TEST_CASE(simplifyTypedef101); // ticket #3003 (segmentation fault) + TEST_CASE(simplifyTypedef102); // ticket #3004 TEST_CASE(simplifyTypedefFunction1); TEST_CASE(simplifyTypedefFunction2); // ticket #1685 @@ -5393,6 +5394,17 @@ private: ASSERT_EQUALS("[test.cpp:2]: (error) syntax error\n", errout.str()); } + void simplifyTypedef102() // ticket #3004 + { + const char code[] = "typedef struct { } Fred;\n" + "void foo()\n" + "{\n" + " Fred * Fred;\n" + "}\n"; + sizeof_(code); + ASSERT_EQUALS("", errout.str()); + } + void simplifyTypedefFunction1() { {